Fix translate option
This commit is contained in:
parent
764caffd74
commit
140440b224
8 changed files with 62 additions and 47 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
</a>
|
</a>
|
||||||
<a ng-show="goBackToState"
|
<a ng-show="goBackToState"
|
||||||
ng-click="$root.go(goBackToState); goBackToState = null"><i class="icon-arrow-left3 icon-back"></i>
|
ng-click="$root.go(goBackToState); goBackToState = null"><i class="icon-arrow-left3 icon-back"></i>
|
||||||
<span class="text-back" translate>Back</span>
|
<span class="text-back">{{'Back'|translate}}</span>
|
||||||
</a>
|
</a>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
<span translate>Language</span>
|
<span translate>Language</span>
|
||||||
<span class="right text-gray">
|
<span class="right text-gray">
|
||||||
<i class="icon-arrow-right3 size-24 right"></i>
|
<i class="icon-arrow-right3 size-24 right"></i>
|
||||||
{{preferences.getDefaultLanguageName(index.availableLanguages)}}
|
{{index.defaultLanguageName}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
ng-repeat="lang in index.availableLanguages"
|
ng-repeat="lang in index.availableLanguages"
|
||||||
ng-click="prefLang.save(lang.isoCode)" class="line-b p20 size-14">
|
ng-click="prefLang.save(lang.isoCode)" class="line-b p20 size-14">
|
||||||
<span>{{lang.name}}</span>
|
<span>{{lang.name}}</span>
|
||||||
<i class="fi-check size-16 right" ng-show="prefLang.defaultLanguage == lang.isoCode"></i>
|
<i class="fi-check size-16 right" ng-show="index.defaultLanguageIsoCode == lang.isoCode"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="extra-margin-bottom"></div>
|
<div class="extra-margin-bottom"></div>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
'use strict';
|
'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;
|
var self = this;
|
||||||
self.isCordova = isCordova;
|
self.isCordova = isCordova;
|
||||||
self.onGoingProcess = {};
|
self.onGoingProcess = {};
|
||||||
self.limitHistory = 5;
|
self.limitHistory = 5;
|
||||||
|
|
||||||
function strip(number) {
|
function strip(number) {
|
||||||
return (parseFloat(number.toPrecision(12)));
|
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
|
// UX event handlers
|
||||||
$rootScope.$on('Local/ColorUpdated', function(event) {
|
$rootScope.$on('Local/ColorUpdated', function(event) {
|
||||||
self.updateColor();
|
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) {
|
$rootScope.$on('Animation/Disable', function(event) {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.swipeLeft = false;
|
self.swipeLeft = false;
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.getDefaultLanguageName = function(availableLanguages) {
|
|
||||||
var defaultLanguage = config.wallet.settings.defaultLanguage || 'en';
|
|
||||||
return lodash.result(lodash.find(availableLanguages, { 'isoCode': defaultLanguage }), 'name');
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
unwatch();
|
unwatch();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesLanguageController',
|
angular.module('copayApp.controllers').controller('preferencesLanguageController',
|
||||||
function($scope, $timeout, configService, applicationService) {
|
function($scope, $timeout, go) {
|
||||||
this.defaultLanguage = configService.getSync().wallet.settings.defaultLanguage || 'en';
|
|
||||||
|
|
||||||
this.save = function(newLang) {
|
this.save = function(newLang) {
|
||||||
var opts = {
|
$scope.$emit('Local/DefaultLanguage', newLang);
|
||||||
wallet: {
|
|
||||||
settings: {
|
|
||||||
defaultLanguage: newLang
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.loading = true;
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
configService.set(opts, function(err) {
|
go.preferences();
|
||||||
if (err) console.log(err);
|
|
||||||
applicationService.restart();
|
|
||||||
});
|
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -432,32 +432,21 @@ angular
|
||||||
needProfile: false
|
needProfile: false
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService, configService) {
|
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService) {
|
||||||
|
|
||||||
var userLang = configService.getSync().wallet.settings.defaultLanguage;
|
// Auto-detect browser language
|
||||||
if (!userLang) {
|
var userLang, androidLang;
|
||||||
// Auto-detect browser language
|
|
||||||
var androidLang;
|
|
||||||
|
|
||||||
if (navigator && navigator.userAgent && (androidLang = navigator.userAgent.match(/android.*\W(\w\w)-(\w\w)\W/i))) {
|
if (navigator && navigator.userAgent && (androidLang = navigator.userAgent.match(/android.*\W(\w\w)-(\w\w)\W/i))) {
|
||||||
userLang = androidLang[1];
|
userLang = androidLang[1];
|
||||||
} else {
|
} else {
|
||||||
// works for iOS and Android 4.x
|
// works for iOS and Android 4.x
|
||||||
userLang = navigator.userLanguage || navigator.language;
|
userLang = navigator.userLanguage || navigator.language;
|
||||||
}
|
|
||||||
userLang = userLang ? (userLang.split('-', 1)[0] || 'en') : 'en';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configService.set({
|
userLang = userLang ? (userLang.split('-', 1)[0] || 'en') : 'en';
|
||||||
wallet: {
|
gettextCatalog.setCurrentLanguage(userLang);
|
||||||
settings: {
|
amMoment.changeLocale(userLang);
|
||||||
defaultLanguage: userLang
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, function() {
|
|
||||||
gettextCatalog.setCurrentLanguage(userLang);
|
|
||||||
amMoment.changeLocale(userLang);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register URI handler, not for mobileApp
|
// Register URI handler, not for mobileApp
|
||||||
if (!isCordova) {
|
if (!isCordova) {
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
configService.get(function(err) {
|
configService.get(function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
$rootScope.$emit('Local/DefaultLanguage');
|
||||||
root.setWalletClients();
|
root.setWalletClients();
|
||||||
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue