update on switching langanges of UI.

This commit is contained in:
kunw 2016-06-22 19:56:21 +08:00
parent 5acf9ea114
commit 169ebf0ee4
2 changed files with 5 additions and 4 deletions

View File

@ -14,13 +14,15 @@
vm.currentLanguage = I18nService().getCurrentLanguage();
vm.languageName = I18nService().getLanguageName(vm.currentLanguage);
I18nService().setCurrentLanguage(vm.currentLanguage);
console.log('current language:' + vm.languageName);
vm.supportLanguages = I18nService().getSupportLanguages();
vm.user = currentUser.get();
vm.setLanguage = setLanguage;
vm.logOut = logOut;
function setLanguage(language) {
I18nService().setCurrentLanguage(language);
$window.location.href = '/language?lang=' + language;

View File

@ -13,7 +13,7 @@
var cookieOptions = {'path': '/'};
var messages = $.extend(true, {}, eval('locale_messages'));
var defaultLanguage = navigator.language || 'en-US';
var defaultLanguage = 'en-US';
var supportLanguages = {
'en-US': 'English',
'zh-CN': '中文'
@ -36,11 +36,9 @@
if(!angular.isDefined(language) || !isSupportLanguage(language)) {
language = defaultLanguage;
}
$cookies.remove('language', cookieOptions);
$cookies.put('language', language, cookieOptions);
},
'setDefaultLanguage': function() {
$cookies.remove('language', cookieOptions);
$cookies.put('language', defaultLanguage, cookieOptions);
},
'getCurrentLanguage': function() {
@ -50,6 +48,7 @@
if(!angular.isDefined(language) || !isSupportLanguage(language)) {
language = defaultLanguage;
}
$cookies.put('language', language, cookieOptions);
return supportLanguages[language];
},
'getSupportLanguages': function() {