Fix translate option
This commit is contained in:
parent
764caffd74
commit
140440b224
8 changed files with 62 additions and 47 deletions
|
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, gettextCatalog, amMoment) {
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
self.limitHistory = 5;
|
||||
self.limitHistory = 5;
|
||||
|
||||
function strip(number) {
|
||||
return (parseFloat(number.toPrecision(12)));
|
||||
|
|
@ -433,6 +433,44 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
self.setDefaultLanguage = function(setLang) {
|
||||
var userLang
|
||||
if (!setLang) {
|
||||
userLang = configService.getSync().wallet.settings.defaultLanguage;
|
||||
if (!userLang) {
|
||||
// Auto-detect browser language
|
||||
var 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';
|
||||
}
|
||||
if (userLang != gettextCatalog.getCurrentLanguage()) {
|
||||
$log.debug('Setting default language: ' + userLang);
|
||||
gettextCatalog.setCurrentLanguage(userLang);
|
||||
amMoment.changeLocale(userLang);
|
||||
}
|
||||
}
|
||||
else {
|
||||
configService.set({
|
||||
wallet: {
|
||||
settings: {
|
||||
defaultLanguage: setLang
|
||||
}
|
||||
}
|
||||
}, function() {
|
||||
gettextCatalog.setCurrentLanguage(setLang);
|
||||
amMoment.changeLocale(setLang);
|
||||
});
|
||||
}
|
||||
self.defaultLanguageIsoCode = setLang || userLang;
|
||||
self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, { 'isoCode': self.defaultLanguageIsoCode }), 'name');
|
||||
};
|
||||
|
||||
// UX event handlers
|
||||
$rootScope.$on('Local/ColorUpdated', function(event) {
|
||||
self.updateColor();
|
||||
|
|
@ -499,6 +537,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/DefaultLanguage', function(event, setLang) {
|
||||
self.setDefaultLanguage(setLang);
|
||||
});
|
||||
|
||||
$rootScope.$on('Animation/Disable', function(event) {
|
||||
$timeout(function() {
|
||||
self.swipeLeft = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue