Commit 6aceba9d authored by Wescoeur's avatar Wescoeur

feat(ui/views/App/Settings/SettingsUi): ask restart to user when language is updated

parent 2cd19ab5
...@@ -1277,6 +1277,10 @@ your friend&apos;s SIP address or username.</translation> ...@@ -1277,6 +1277,10 @@ your friend&apos;s SIP address or username.</translation>
<source>downloadLabel</source> <source>downloadLabel</source>
<translation>Download folder</translation> <translation>Download folder</translation>
</message> </message>
<message>
<source>setLocaleDescription</source>
<translation>It is necessary to restart the application. Do you want to restart now?</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsVideo</name> <name>SettingsVideo</name>
......
...@@ -1275,6 +1275,10 @@ Url du serveur non configurée.</translation> ...@@ -1275,6 +1275,10 @@ Url du serveur non configurée.</translation>
<source>downloadLabel</source> <source>downloadLabel</source>
<translation>Dossier des téléchargements</translation> <translation>Dossier des téléchargements</translation>
</message> </message>
<message>
<source>setLocaleDescription</source>
<translation>Voulez-vous redémarrer maintenant pour prendre en compte ces modifications ?</translation>
</message>
</context> </context>
<context> <context>
<name>SettingsVideo</name> <name>SettingsVideo</name>
......
...@@ -17,3 +17,35 @@ function cleanAvatars () { ...@@ -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()
}
})
}
...@@ -28,34 +28,11 @@ TabContainer { ...@@ -28,34 +28,11 @@ TabContainer {
label: qsTr('languagesLabel') label: qsTr('languagesLabel')
ComboBox { 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' textRole: 'key'
model: ListModel {}
Component.onCompleted: { Component.onCompleted: {
var locales = _getAvailableLocales() var locales = Logic.getAvailableLocales()
model = locales
model.append({
key: qsTr('systemLocale'),
value: ''
})
locales.forEach(function (locale) {
model.append(locale)
})
var locale = App.configLocale var locale = App.configLocale
if (!locale.length) { if (!locale.length) {
...@@ -64,14 +41,12 @@ TabContainer { ...@@ -64,14 +41,12 @@ TabContainer {
} }
var value = Qt.locale(locale).name var value = Qt.locale(locale).name
var index = Utils.findIndex(locales, function (locale) { currentIndex = Number(Utils.findIndex(locales, function (locale) {
return locale.value === value return locale.value === value
}) }))
currentIndex = index != null ? index + 1 : 0
} }
onActivated: App.configLocale = model.get(index).value onActivated: Logic.setLocale(model[index].value)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment