From a67213fb7b590834fdb77947973ad058b596791c Mon Sep 17 00:00:00 2001 From: Tomazed Date: Mon, 30 Jan 2023 15:07:36 +0100 Subject: [PATCH] Simplified languageCodeMap maintainability --- client/plugins/i18n.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/plugins/i18n.js b/client/plugins/i18n.js index 5616ea8e..50ff6af1 100644 --- a/client/plugins/i18n.js +++ b/client/plugins/i18n.js @@ -5,18 +5,18 @@ import { supplant } from './utils' const defaultCode = 'en-us' const languageCodeMap = { - 'de': 'Deutsch', - 'en-us': 'English', - // 'es': 'Español', - 'fr': 'Français', - 'hr': 'Hrvatski', - 'it': 'Italiano', - 'pl': 'Polski', - 'zh-cn': '简体中文 (Simplified Chinese)' + 'de': { label: 'Deutsch', dateFnsLocale: 'de' }, + 'en-us': { label: 'English', dateFnsLocale: 'enUS' }, + // 'es': { label: 'Español', dateFnsLocale: 'es' }, + 'fr': { label: 'Français', dateFnsLocale: 'fr' }, + 'hr': { label: 'Hrvatski', dateFnsLocale: 'hr' }, + 'it': { label: 'Italiano', dateFnsLocale: 'it' }, + 'pl': { label: 'Polski', dateFnsLocale: 'pl' }, + 'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'znCN' }, } Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => { return { - text: languageCodeMap[code], + text: languageCodeMap[code].label, value: code } }) @@ -73,8 +73,8 @@ async function loadi18n(code) { for (const key in Vue.prototype.$strings) { Vue.prototype.$strings[key] = strings[key] || translations[defaultCode][key] } - console.log(`ConfigDateFnsLocale = ${translations[code].ConfigDateFnsLocale}`) - Vue.prototype.$setDateFnsLocale(translations[code].ConfigDateFnsLocale) + console.log(`dateFnsLocale = ${languageCodeMap[code].dateFnsLocale}`) + Vue.prototype.$setDateFnsLocale(languageCodeMap[code].dateFnsLocale) console.log('i18n strings=', Vue.prototype.$strings) Vue.prototype.$eventBus.$emit('change-lang', code)