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

@ -147,5 +147,7 @@
"CHAT_VOL_MINUS": "Vol -",
"CHAT_VOL_PLUS": "Vol +",
"CHAT_GAIN_MINUS": "Gain -",
"CHAT_GAIN_PLUS": "Gain +"
"CHAT_GAIN_PLUS": "Gain +",
"LANGUAGE": "Language:",
"BROWSER_LANGUAGE": "Browser Language"
}

View File

@ -148,6 +148,8 @@
"CHAT_VOL_MINUS": "Vol -",
"CHAT_VOL_PLUS": "Vol +",
"CHAT_GAIN_MINUS": "Guadagno -",
"CHAT_GAIN_PLUS": "Guadagno +"
"CHAT_GAIN_PLUS": "Guadagno +",
"LANGUAGE": "Lingua:",
"BROWSER_LANGUAGE": "Lingua del browser"
}

View File

@ -79,6 +79,14 @@
</label>
</div>
<div class="form-group">
<label for="settings-language">{{ 'LANGUAGE' | translate }}</label>
<select name="mylanguage" id="settings-language" class="form-control"
ng-model="mydata.language" ng-change="changedLanguage(mydata.language)"
ng-options="item.id as item.name for item in languages">
</select>
</div>
<div class="form-group">
<label for="settings-microphone">{{ 'AUDIO_SETTINGS' | translate }}</label>
<div class="checkbox">

View File

@ -39,7 +39,8 @@
googEchoCancellation: true,
autoBand: true,
testSpeedJoin: true,
bestFrameRate: "15"
bestFrameRate: "15",
language: undefined
};
data.$default(defaultSettings);

View File

@ -20,8 +20,58 @@
'pascalprecht.translate',
]);
vertoApp.config(['$routeProvider', 'gravatarServiceProvider', '$translateProvider',
function($routeProvider, gravatarServiceProvider, $translateProvider) {
vertoApp.constant('configLanguages', {
'languages' : [
{id: 'en', name: 'English'},
{id: 'it', name: 'Italiano'},
{id: 'fr', name: 'Français'},
{id: 'de', name: 'Deutsch'},
{id: 'pt', name: 'Português'},
{id: 'pl', name: 'Polski'},
{id: 'zh', name: '中國'},
{id: 'ru', name: 'Pусский'},
{id: 'sv', name: 'Svenska'},
{id: 'da', name: 'Dansk'},
{id: 'es', name: 'Español'},
{id: 'id', name: 'Indonesia'}
],
'dialects' : {
'en': 'en',
'en_GB': 'en',
'en_US': 'en',
'it': 'it',
'it_IT': 'it',
'fr': 'fr',
'fr_FR': 'fr',
'fr_CA': 'fr',
'pt': 'pt',
'pt_BR': 'pt',
'pt_PT': 'pt',
'de': 'de',
'de_DE': 'de',
'es': 'es',
'es_ES': 'es',
'pl': 'pl',
'pl_PL': 'pl',
'ru': 'ru',
'ru_RU': 'ru',
'sv': 'sv',
'sv_SV': 'sv',
'sv_FI': 'sv',
'da': 'da',
'da_DK': 'da',
'id': 'id',
'id_ID': 'id',
'zh': 'zh',
'zh_CN': 'zh',
'zh_TW': 'zh',
'zh_HK': 'zh'
}
});
vertoApp.config(['$routeProvider', 'gravatarServiceProvider', '$translateProvider', 'configLanguages',
function($routeProvider, gravatarServiceProvider, $translateProvider, configLanguages) {
$routeProvider.
when('/', {
title: 'Loading',
@ -61,44 +111,17 @@
default: 'mm' // Mystery man as default for missing avatars
};
var reg_langs = [];
angular.forEach(configLanguages.languages, function(value, key) {
reg_langs.push(value.id);
});
$translateProvider
.useStaticFilesLoader({
prefix: 'locales/locale-',
suffix: '.json'
})
.registerAvailableLanguageKeys(['en', 'it', 'pt', 'fr', 'da', 'de', 'es', 'pl', 'ru', 'sv', 'id', 'zh'], {
'en': 'en',
'en_GB': 'en',
'en_US': 'en',
'it': 'it',
'it_IT': 'it',
'fr': 'fr',
'fr_FR': 'fr',
'fr_CA': 'fr',
'pt': 'pt',
'pt_BR': 'pt',
'pt_PT': 'pt',
'da': 'da',
'da_DK': 'da',
'de': 'de',
'de_DE': 'de',
'es': 'es',
'es_ES': 'es',
'pl': 'pl',
'pl_PL': 'pl',
'ru': 'ru',
'ru_RU': 'ru',
'sv': 'sv',
'sv_SV': 'sv',
'sv_FI': 'sv',
'id': 'id',
'id_ID': 'id',
'zh': 'zh',
'zh_CN': 'zh',
'zh_TW': 'zh',
'zh_HK': 'zh'
})
.registerAvailableLanguageKeys(reg_langs, configLanguages.dialects)
.preferredLanguage('en')
.determinePreferredLanguage()
.fallbackLanguage('en')

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();
};