FS-9006 - [verto_communicator] add-combobox for languages

This commit is contained in:
Davide Colombo
2016-04-08 11:37:20 +02:00
parent e4add83915
commit 817a10be14
7 changed files with 104 additions and 39 deletions

View File

@@ -8,6 +8,12 @@
console.debug('Executing MainController.');
if (storage.data.language && storage.data.language !== 'browser') {
$translate.use(storage.data.language);
} else {
storage.data.language = 'browser';
}
$rootScope.master = $location.search().master;
if ($location.search().watcher === 'true') {
$rootScope.watcher = true;

View File

@@ -4,8 +4,8 @@
angular
.module('vertoControllers')
.controller('SettingsController', ['$scope', '$http',
'$location', '$rootScope', 'storage', 'verto', '$translate', 'toastr',
function($scope, $http, $location, $rootScope, storage, verto, $translate, toastr) {
'$location', '$rootScope', 'storage', 'verto', '$translate', 'toastr', 'configLanguages',
function($scope, $http, $location, $rootScope, storage, verto, $translate, toastr, configLanguages) {
console.debug('Executing ModalSettingsController.');
$.material.init();
@@ -14,6 +14,15 @@
$scope.storage = storage;
$scope.verto = verto;
$scope.mydata = angular.copy(storage.data);
$scope.languages = configLanguages.languages;
$scope.languages.unshift({id: 'browser', name : $translate.instant('BROWSER_LANGUAGE')});
$scope.mydata.language = storage.data.language || 'browser';
$rootScope.$on('$translateChangeSuccess', function () {
$translate('BROWSER_LANGUAGE').then(function (translation) {
$scope.languages[0].name = translation;
});
});
$rootScope.$on('toggledSettings', function(e, status) {
if (status) {
@@ -35,6 +44,20 @@
}
};
$scope.changedLanguage = function(langKey){
if (langKey === 'browser'){
storage.data.language = 'browser';
var browserlang = $translate.preferredLanguage();
$translate.use(browserlang).then(
function(lang) {}, function(fail_lang) {
$translate.use('en');
});
} else {
$translate.use(langKey);
storage.data.language = langKey;
}
};
$scope.refreshDeviceList = function() {
return verto.refreshDevices();
};