Merge pull request #58 from JDonadio/bug/language

Fix language
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-05 12:41:58 -03:00 committed by GitHub
commit 9bfb38d819
2 changed files with 13 additions and 24 deletions

View file

@ -22,7 +22,7 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController
if (err) $log.warn(err);
$ionicHistory.goBack();
uxLanguage.update(function() {
uxLanguage.init(function() {
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
$log.debug('Remote preferences saved');
});

View file

@ -72,7 +72,8 @@ angular.module('copayApp.services')
root._set = function(lang) {
$log.debug('Setting default language: ' + lang);
gettextCatalog.setCurrentLanguage(lang);
root.currentLanguage = lang;
root.currentLanguage = lang;
if (lang == 'zh') lang = lang + '-CN'; // Fix for Chinese Simplified
amMoment.changeLocale(lang);
};
@ -95,31 +96,19 @@ angular.module('copayApp.services')
return root.availableLanguages;
};
root.init = function() {
root._detect(function(lang) {
root._set(lang);
});
};
root.init = function(cb) {
configService.whenAvailable(function(config) {
var userLang = config.wallet.settings.defaultLanguage;
root.update = function(cb) {
var userLang = configService.getSync().wallet.settings.defaultLanguage;
if (!userLang) {
root._detect(function(lang) {
userLang = lang;
if (userLang != root.currentLanguage) {
root._set(lang);
}
if (cb) return cb(userLang);
});
} else {
if (userLang != root.currentLanguage) {
if (userLang && userLang != root.currentLanguage) {
root._set(userLang);
} else {
root._detect(function(lang) {
root._set(lang);
});
}
if (cb) return cb(userLang);
}
if (cb) return cb();
});
};
root.getName = function(lang) {