2015-04-22 15:19:08 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copayApp.controllers').controller('preferencesLanguageController',
|
2016-08-29 16:48:15 -03:00
|
|
|
function($scope, $log, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, configService, profileService, uxLanguage, walletService) {
|
|
|
|
|
$ionicNavBarDelegate.title(gettextCatalog.getString('Language'));
|
2015-04-22 15:19:08 -03:00
|
|
|
|
2016-08-15 17:42:04 -03:00
|
|
|
$scope.init = function() {
|
|
|
|
|
$scope.availableLanguages = uxLanguage.getLanguages();
|
|
|
|
|
$scope.currentLanguage = uxLanguage.getCurrentLanguage();
|
|
|
|
|
}
|
2015-08-27 12:07:13 -03:00
|
|
|
|
2016-06-10 09:35:44 -03:00
|
|
|
$scope.save = function(newLang) {
|
2015-06-29 21:46:34 -03:00
|
|
|
var opts = {
|
|
|
|
|
wallet: {
|
|
|
|
|
settings: {
|
|
|
|
|
defaultLanguage: newLang
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
configService.set(opts, function(err) {
|
|
|
|
|
if (err) $log.warn(err);
|
2016-06-06 18:26:45 -03:00
|
|
|
|
2016-08-29 16:48:15 -03:00
|
|
|
$ionicHistory.goBack();
|
2016-06-06 18:26:45 -03:00
|
|
|
uxLanguage.update(function() {
|
2016-08-23 12:01:09 -03:00
|
|
|
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
|
2016-06-09 17:20:17 -03:00
|
|
|
$log.debug('Remote preferences saved');
|
|
|
|
|
});
|
2016-06-06 18:26:45 -03:00
|
|
|
});
|
2015-06-29 21:46:34 -03:00
|
|
|
});
|
2015-04-22 15:19:08 -03:00
|
|
|
};
|
|
|
|
|
});
|