Search code examples
angularjsangular-translate

Angular Translate doesn't work with multiple translation IDs


This doesn't work. Returns a blank.

 $translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (investEdu, mostUltimate) {

Then I tried this, with an object:

 $translate('INVEST_EDU', 'MOST_ULTIMATE').then(function (translations) {

Accessing it like `translations.INVEST_EDU'. First one appears, second one blank.

What am I doing wrong here, in making Angular-translate work with multiple translation IDs.


Solution

  • Angular translate usage:

    $translate(translationId[, interpolateParams], interpolationId);

    translationId [string | array] - A token which represents a translation id This can be optionally an array of translation ids which results that the function returns an object where each key is the translation id and the value the translation.

    interpolateParams(optional) [object]-An object hash for dynamic values

    interpolationId [string] - The id of the interpolation to use

    http://angular-translate.github.io/docs/#/api/pascalprecht.translate.$translate

    This means, if you want multiple translation ids you call soemthing like $translate(['INVEST_EDU','MOST_ULTIMATE']).then(function(results){...}