in my app I would like to add functionality to translate page into all languages that user has set in browser and if none of them is available translate into default english... Problem is browser inconsistency with language support. I found a workaround for this, I make a http call to some webservice which returns user languages. It is done in app.run
app.run(function($rootScope, UserDataService, $translate){ UserDataService.getUserBrowserLanguage().then(function(language){ var langArr = language.split(',').map(function(el){ return el.split(';')[0].split(/-|_/)[0]; }); $translate.fallbackLanguage(langArr) $translate.preferredLanguage(langArr[0]); $translate.use(langArr[0]); }); });
and in app config:
app.config(function ($routeProvider, $translateProvider) { $translateProvider.useStaticFilesLoader({ prefix: '/languages/', suffix: '.json' }); }); section because I can't make http call in config and it fails... :/ langauges are loaded but the translation isn't changed... What am I doing wrong? Here is plunker:
http://plnkr.co/edit/41SngK2tCTeaq8IhMbcM
it doesn't display anything no translations... why? :( I would be very pleased with any help.