Use language names for selectors
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/* global angular:false */
|
||||
/* global $:false */
|
||||
|
||||
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$rootScope', '$timeout', 'Client', function ($scope, $location, $rootScope, $timeout, Client) {
|
||||
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$translate', '$rootScope', '$timeout', 'Client', function ($scope, $location, $translate, $rootScope, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
|
||||
|
||||
$scope.client = Client;
|
||||
@@ -212,7 +212,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
$scope.language.busy = true;
|
||||
$scope.language.success = false;
|
||||
|
||||
Client.setLanguage($scope.language.language, function (error) {
|
||||
Client.setLanguage($scope.language.language.id, function (error) {
|
||||
if (error) $scope.language.error = error.message;
|
||||
else $scope.language.currentLanguage = $scope.language.language;
|
||||
|
||||
@@ -293,15 +293,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
});
|
||||
}
|
||||
|
||||
function getLanguage() {
|
||||
Client.getLanguage(function (error, languageKey) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.language.currentLanguage = Client.getAvailableLanguages().find(function (key) { return key === languageKey; });
|
||||
$scope.language.language = $scope.language.currentLanguage;
|
||||
});
|
||||
}
|
||||
|
||||
function getAutoupdatePattern() {
|
||||
Client.getAutoupdatePattern(function (error, result) {
|
||||
if (error) return console.error(error);
|
||||
@@ -394,7 +385,16 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
getAutoupdatePattern();
|
||||
getRegistryConfig();
|
||||
getTimeZone();
|
||||
getLanguage();
|
||||
|
||||
$translate.onReady(function () {
|
||||
Client.getLanguage(function (error, usedLang) {
|
||||
if (error) return console.error('Unable to fetch language:', error);
|
||||
|
||||
$scope.language.availableLanguages = Client.getAvailableLanguages().map(function (l) { return { display: $translate.instant('lang.'+l), id: l }});
|
||||
$scope.language.currentLanguage = $scope.language.availableLanguages.find(function (l) { return l.id === usedLang; });
|
||||
$scope.language.language = $scope.language.currentLanguage;
|
||||
});
|
||||
});
|
||||
|
||||
$scope.update.checkStatus();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user