diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index a759cd9f3..ac1cba2e9 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -1277,6 +1277,10 @@ your friend's SIP address or username. downloadLabel Download folder + + setLocaleDescription + It is necessary to restart the application. Do you want to restart now? + SettingsVideo diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index d157e9380..262a14681 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -1275,6 +1275,10 @@ Url du serveur non configurée. downloadLabel Dossier des téléchargements + + setLocaleDescription + Voulez-vous redémarrer maintenant pour prendre en compte ces modifications ? + SettingsVideo diff --git a/linphone-desktop/ui/views/App/Settings/SettingsUi.js b/linphone-desktop/ui/views/App/Settings/SettingsUi.js index e7f5b09ee..87f0af8bd 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsUi.js +++ b/linphone-desktop/ui/views/App/Settings/SettingsUi.js @@ -17,3 +17,35 @@ function cleanAvatars () { } }) } + +function getAvailableLocales () { + var locales = [] + + Linphone.App.availableLocales.forEach(function (locale) { + locales.push({ + key: Utils.capitalizeFirstLetter(locale.nativeLanguageName), + value: locale.name + }) + }) + + return [{ + key: qsTr('systemLocale'), + value: '' + }].concat(locales.sort(function (a, b) { + return a > b + })) +} + +function setLocale (locale) { + var App = Linphone.App + App.configLocale = locale + + window.detachVirtualWindow() + window.attachVirtualWindow(Utils.buildDialogUri('ConfirmDialog'), { + descriptionText: qsTr('setLocaleDescription'), + }, function (status) { + if (status) { + App.restart() + } + }) +} diff --git a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml index e1352b7b2..a70c98c82 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsUi.qml +++ b/linphone-desktop/ui/views/App/Settings/SettingsUi.qml @@ -28,34 +28,11 @@ TabContainer { label: qsTr('languagesLabel') ComboBox { - function _getAvailableLocales () { - var locales = [] - - App.availableLocales.forEach(function (locale) { - locales.push({ - key: Utils.capitalizeFirstLetter(locale.nativeLanguageName), - value: locale.name - }) - }) - - return locales.sort(function (a, b) { - return a > b - }) - } - textRole: 'key' - model: ListModel {} Component.onCompleted: { - var locales = _getAvailableLocales() - - model.append({ - key: qsTr('systemLocale'), - value: '' - }) - locales.forEach(function (locale) { - model.append(locale) - }) + var locales = Logic.getAvailableLocales() + model = locales var locale = App.configLocale if (!locale.length) { @@ -64,14 +41,12 @@ TabContainer { } var value = Qt.locale(locale).name - var index = Utils.findIndex(locales, function (locale) { + currentIndex = Number(Utils.findIndex(locales, function (locale) { return locale.value === value - }) - - currentIndex = index != null ? index + 1 : 0 + })) } - onActivated: App.configLocale = model.get(index).value + onActivated: Logic.setLocale(model[index].value) } } }