Skip to content

Commit

Permalink
Autodetect device language. Removed select language from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgustavo committed Feb 23, 2015
1 parent e700634 commit e213770
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ module.exports = function(grunt) {
'lib/file-saver/FileSaver.js',
'lib/socket.io-client/socket.io.js',
'lib/sjcl.js',
'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js'
'lib/qrcode-decoder-js/lib/qrcode-decoder.min.js',
'lib/moment/lang/*.js'
],
dest: 'lib/vendors.js'
},
Expand Down
1 change: 0 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
var defaultConfig = {
defaultLanguage: 'en',
// DEFAULT network (livenet or testnet)
networkName: 'livenet',
logLevel: 'info',
Expand Down
17 changes: 0 additions & 17 deletions js/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $route, $location, notification, configService) {
$scope.title = 'Settings';
$scope.defaultLanguage = config.defaultLanguage || 'en';
$scope.insightLivenet = config.network.livenet.url;
$scope.insightTestnet = config.network.testnet.url;
$scope.defaultLogLevel = config.logLevel || 'log';
Expand Down Expand Up @@ -35,21 +34,6 @@ angular.module('copayApp.controllers').controller('SettingsController', function
$scope.selectedStorage = v;
});

$scope.availableLanguages = [{
name: 'English',
isoCode: 'en',
}, {
name: 'Spanish',
isoCode: 'es',
}];

for (var ii in $scope.availableLanguages) {
if ($scope.defaultLanguage === $scope.availableLanguages[ii].isoCode) {
$scope.selectedLanguage = $scope.availableLanguages[ii];
break;
}
}

for (var ii in $scope.availableLogLevels) {
if ($scope.defaultLogLevel === $scope.availableLogLevels[ii].name) {
$scope.selectedLogLevel = $scope.availableLogLevels[ii];
Expand Down Expand Up @@ -77,7 +61,6 @@ angular.module('copayApp.controllers').controller('SettingsController', function

configService.set({
network: insightSettings,
defaultLanguage: $scope.selectedLanguage.isoCode,
plugins: plugins,
logLevel: $scope.selectedLogLevel.name,
EncryptedInsightStorage: _.extend(config.EncryptedInsightStorage, {
Expand Down
15 changes: 13 additions & 2 deletions js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,20 @@ angular
$idleProvider.warningDuration(40); // in seconds
$keepaliveProvider.interval(30); // in seconds
})
.run(function($rootScope, $location, $idle, gettextCatalog, uriHandler, isCordova) {
.run(function($rootScope, $location, $idle, gettextCatalog, uriHandler, isCordova, amMoment) {

gettextCatalog.currentLanguage = config.defaultLanguage;
var userLang, 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.split('-', 1)[0];
gettextCatalog.setCurrentLanguage(userLang);
amMoment.changeLanguage(userLang);

// Register URI handler, not for mobileApp
if (!isCordova) {
Expand Down
3 changes: 0 additions & 3 deletions js/services/configService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ angular.module('copayApp.services').factory('configService', function($timeout,
if (opts.logLevel)
copay.logger.setLevel(opts.logLevel);

if (opts.defaultLanguage)
gettextCatalog.currentLanguage = opts.defaultLanguage;

// Set current version
opts.version = copay.version;

Expand Down
5 changes: 0 additions & 5 deletions views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ <h2>{{title|translate}}</h2>
More pluggins are welcomed!</a>
</small>
</fieldset>
<fieldset>
<legend translate>Language</legend>
<select class="form-control" ng-model="selectedLanguage" ng-options="o.name for o in availableLanguages" required>
</select>
</fieldset>
<fieldset>
<legend translate>Log level</legend>
<select class="form-control" ng-model="selectedLogLevel" ng-options="o.name for o in availableLogLevels" required>
Expand Down

0 comments on commit e213770

Please sign in to comment.