2
votes

I know that in controller I can use $translate.instant('HELLO_WORLD'), to get the translate to the 'current' set language.

What if the current is french, and I want to get english of 'HELLO_WORLD' too, but not changing the user's current preferred language.

The reason I want this is casue my app let user switch between french and english at any time. Everything works except for a directive that uses a $rootScope.object, the words inside doesnt get updated when user change the language.

The way Im trying to do it by is, I use a listener on this rootScope.object, when it get change, I manually change the item inside. However I need to know both french and english translate of each word to make the comparison and change.

1

1 Answers

0
votes

The $translate.instant() API has a force language parameter. If you know your supported languages ahead of time you could query them all using separate calls to .instant().

instant(translationId, interpolateParams, interpolationId, forceLanguage, sanitizeStrategy)