mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-30 18:48:55 +01:00
Simplified languageCodeMap maintainability
This commit is contained in:
parent
b5de517aad
commit
a67213fb7b
@ -5,18 +5,18 @@ import { supplant } from './utils'
|
|||||||
const defaultCode = 'en-us'
|
const defaultCode = 'en-us'
|
||||||
|
|
||||||
const languageCodeMap = {
|
const languageCodeMap = {
|
||||||
'de': 'Deutsch',
|
'de': { label: 'Deutsch', dateFnsLocale: 'de' },
|
||||||
'en-us': 'English',
|
'en-us': { label: 'English', dateFnsLocale: 'enUS' },
|
||||||
// 'es': 'Español',
|
// 'es': { label: 'Español', dateFnsLocale: 'es' },
|
||||||
'fr': 'Français',
|
'fr': { label: 'Français', dateFnsLocale: 'fr' },
|
||||||
'hr': 'Hrvatski',
|
'hr': { label: 'Hrvatski', dateFnsLocale: 'hr' },
|
||||||
'it': 'Italiano',
|
'it': { label: 'Italiano', dateFnsLocale: 'it' },
|
||||||
'pl': 'Polski',
|
'pl': { label: 'Polski', dateFnsLocale: 'pl' },
|
||||||
'zh-cn': '简体中文 (Simplified Chinese)'
|
'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'znCN' },
|
||||||
}
|
}
|
||||||
Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => {
|
Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => {
|
||||||
return {
|
return {
|
||||||
text: languageCodeMap[code],
|
text: languageCodeMap[code].label,
|
||||||
value: code
|
value: code
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -73,8 +73,8 @@ async function loadi18n(code) {
|
|||||||
for (const key in Vue.prototype.$strings) {
|
for (const key in Vue.prototype.$strings) {
|
||||||
Vue.prototype.$strings[key] = strings[key] || translations[defaultCode][key]
|
Vue.prototype.$strings[key] = strings[key] || translations[defaultCode][key]
|
||||||
}
|
}
|
||||||
console.log(`ConfigDateFnsLocale = ${translations[code].ConfigDateFnsLocale}`)
|
console.log(`dateFnsLocale = ${languageCodeMap[code].dateFnsLocale}`)
|
||||||
Vue.prototype.$setDateFnsLocale(translations[code].ConfigDateFnsLocale)
|
Vue.prototype.$setDateFnsLocale(languageCodeMap[code].dateFnsLocale)
|
||||||
|
|
||||||
console.log('i18n strings=', Vue.prototype.$strings)
|
console.log('i18n strings=', Vue.prototype.$strings)
|
||||||
Vue.prototype.$eventBus.$emit('change-lang', code)
|
Vue.prototype.$eventBus.$emit('change-lang', code)
|
||||||
|
Loading…
Reference in New Issue
Block a user