refactor ux language handling

This commit is contained in:
Matias Alejo Garcia 2015-08-27 12:07:13 -03:00
commit 55afc4d9d4
8 changed files with 125 additions and 81 deletions

View file

@ -463,22 +463,10 @@ angular
needProfile: false
});
})
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService, $timeout, nodeWebkit) {
.run(function($rootScope, $state, $log, uriHandler, isCordova, profileService, $timeout, nodeWebkit, uxLanguage) {
FastClick.attach(document.body);
// Auto-detect browser language
var userLang, androidLang;
if (navigator && navigator.userAgent && (androidLang = navigator.userAgent.match(/android.*\W(\w\w)-(\w\w)\W/i))) {
userLang = androidLang[1];
} else {
// works for iOS and Android 4.x
userLang = navigator.userLanguage || navigator.language;
}
userLang = userLang ? (userLang.split('-', 1)[0] || 'en') : 'en';
gettextCatalog.setCurrentLanguage(userLang);
amMoment.changeLocale(userLang);
uxLanguage.init();
// Register URI handler, not for mobileApp
if (!isCordova) {