refactor ux language handling
This commit is contained in:
parent
39e6a81b62
commit
55afc4d9d4
8 changed files with 125 additions and 81 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, glideraService, $state) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, txFormatService, uxLanguage, $state, glideraService) {
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
|
|
@ -39,35 +39,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.tab = 'walletHome';
|
||||
|
||||
self.availableLanguages = [{
|
||||
name: 'English',
|
||||
isoCode: 'en',
|
||||
}, {
|
||||
name: 'Français',
|
||||
isoCode: 'fr',
|
||||
}, {
|
||||
name: 'Italiano',
|
||||
isoCode: 'it',
|
||||
}, {
|
||||
name: 'Deutsch',
|
||||
isoCode: 'de',
|
||||
}, {
|
||||
name: 'Español',
|
||||
isoCode: 'es',
|
||||
}, {
|
||||
name: 'Português',
|
||||
isoCode: 'pt',
|
||||
}, {
|
||||
name: 'Ελληνικά',
|
||||
isoCode: 'el',
|
||||
}, {
|
||||
name: '日本語',
|
||||
isoCode: 'ja',
|
||||
}, {
|
||||
name: 'Pусский',
|
||||
isoCode: 'ru',
|
||||
}];
|
||||
|
||||
self.feeOpts = feeService.feeOpts;
|
||||
|
||||
self.setOngoingProcess = function(processName, isOn) {
|
||||
|
|
@ -827,29 +798,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
};
|
||||
|
||||
self.setUxLanguage = function() {
|
||||
var 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);
|
||||
}
|
||||
|
||||
var userLang = uxLanguage.update();
|
||||
self.defaultLanguageIsoCode = userLang;
|
||||
self.defaultLanguageName = lodash.result(lodash.find(self.availableLanguages, {
|
||||
'isoCode': self.defaultLanguageIsoCode
|
||||
}), 'name');
|
||||
self.defaultLanguageName = uxLanguage.getName(userLang);
|
||||
};
|
||||
|
||||
self.initGlidera = function(accessToken) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesController',
|
||||
function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService) {
|
||||
function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService, uxLanguage) {
|
||||
var config = configService.getSync();
|
||||
this.unitName = config.wallet.settings.unitName;
|
||||
this.bwsurl = config.bws.url;
|
||||
this.currentLanguageName = uxLanguage.getCurrentLanguageName();
|
||||
this.selectedAlternative = {
|
||||
name: config.wallet.settings.alternativeName,
|
||||
isoCode: config.wallet.settings.alternativeIsoCode
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesLanguageController',
|
||||
function($scope, $log, $timeout, configService, go) {
|
||||
function($scope, $log, $timeout, configService, go, uxLanguage) {
|
||||
|
||||
this.availableLanguages = uxLanguage.getLanguages();
|
||||
|
||||
console.log('[preferencesLanguage.js.7]', this.availableLanguages); //TODO
|
||||
this.save = function(newLang) {
|
||||
|
||||
var opts = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue