[web] Fix settings page not displaying properly when the language is not found

When the user is using a language that is not available in OwnTone, the fallback language is set to English.
This commit is contained in:
Alain Nussbaumer 2023-08-06 10:56:02 +02:00
parent f934aadb67
commit dcbdee6598

View File

@ -197,25 +197,20 @@ export default {
}, },
computed: { computed: {
settings_option_show_composer_now_playing() {
return this.$store.getters.settings_option_show_composer_now_playing
},
settings_option_show_filepath_now_playing() {
return this.$store.getters.settings_option_show_filepath_now_playing
},
locale: { locale: {
get() { get() {
const languages = this.$i18n.availableLocales const languages = this.$i18n.availableLocales
let locale = languages.find((lang) => lang === this.$i18n.locale) let locale = languages.find((lang) => lang === this.$i18n.locale)
let partial = this.$i18n.locale.split('-')[0] const [partial] = this.$i18n.locale.split('-')
if (!locale) { if (!locale) {
locale = languages.find((lang) => lang === partial) locale = languages.find((lang) => lang === partial)
} }
if (!locale) { if (!locale) {
locale = languages.forEach((lang) => lang.split('-')[0] === partial) locale = languages.forEach((lang) => lang.split('-')[0] === partial)
} }
if (!locale) {
locale = this.$i18n.fallbackLocale
}
return locale return locale
}, },
set(locale) { set(locale) {
@ -224,10 +219,17 @@ export default {
}, },
locales: { locales: {
get() { get() {
return this.$i18n.availableLocales.map((item) => { return this.$i18n.availableLocales.map((item) => ({
return { id: item, name: this.$t('language.' + item) } id: item,
}) name: this.$t(`language.${item}`)
}))
} }
},
settings_option_show_composer_now_playing() {
return this.$store.getters.settings_option_show_composer_now_playing
},
settings_option_show_filepath_now_playing() {
return this.$store.getters.settings_option_show_filepath_now_playing
} }
} }
} }