Is there a way to get the translation in a particular language using angualar $translate from inside a controller? $translate.instant(KEY) return the translation of the key based on the selected language . What I need is something like For example if I have already defined the translations in two languages: english and spanish , then $translate.Somefunction(KEY,"languagekey")
I am not a $translate
expert, but can you change the preferred language, do the translation, then switch the preferred language back?
var preferred = $translate.preferredLanguage();
$translate.use('de')
$translate('HEADLINE').then(function(headline){
$scope.translatedGerman = headline;
});
$translate.use(preferred);
Seems to be working in my simple demo at least: http://plnkr.co/edit/tPRbH7Oehy1nycBVopUw?p=preview
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.