From a75ad5d6594274a6ea048e246a1cedbd2dc72cd1 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 16 Jun 2024 09:42:40 -0500 Subject: [PATCH] Add:Finnish language option --- client/plugins/i18n.js | 120 +++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/client/plugins/i18n.js b/client/plugins/i18n.js index 3caf48a8..f2784f14 100644 --- a/client/plugins/i18n.js +++ b/client/plugins/i18n.js @@ -1,36 +1,37 @@ -import Vue from "vue" +import Vue from 'vue' import enUsStrings from '../strings/en-us.json' import { supplant } from './utils' const defaultCode = 'en-us' const languageCodeMap = { - 'bg': { label: 'Български', dateFnsLocale: 'bg' }, - 'bn': { label: 'বাংলা', dateFnsLocale: 'bn' }, - 'cs': { label: 'Čeština', dateFnsLocale: 'cs' }, - 'da': { label: 'Dansk', dateFnsLocale: 'da' }, - 'de': { label: 'Deutsch', dateFnsLocale: 'de' }, + bg: { label: 'Български', dateFnsLocale: 'bg' }, + bn: { label: 'বাংলা', dateFnsLocale: 'bn' }, + cs: { label: 'Čeština', dateFnsLocale: 'cs' }, + da: { label: 'Dansk', dateFnsLocale: 'da' }, + de: { label: 'Deutsch', dateFnsLocale: 'de' }, 'en-us': { label: 'English', dateFnsLocale: 'enUS' }, - 'es': { label: 'Español', dateFnsLocale: 'es' }, - 'et': { label: 'Eesti', dateFnsLocale: 'et' }, - 'fr': { label: 'Français', dateFnsLocale: 'fr' }, - 'he': { label: 'עברית', dateFnsLocale: 'he' }, - 'hr': { label: 'Hrvatski', dateFnsLocale: 'hr' }, - 'it': { label: 'Italiano', dateFnsLocale: 'it' }, - 'lt': { label: 'Lietuvių', dateFnsLocale: 'lt' }, - 'hu': { label: 'Magyar', dateFnsLocale: 'hu' }, - 'nl': { label: 'Nederlands', dateFnsLocale: 'nl' }, - 'no': { label: 'Norsk', dateFnsLocale: 'no' }, - 'pl': { label: 'Polski', dateFnsLocale: 'pl' }, + es: { label: 'Español', dateFnsLocale: 'es' }, + et: { label: 'Eesti', dateFnsLocale: 'et' }, + fi: { label: 'Suomi', dateFnsLocale: 'fi' }, + fr: { label: 'Français', dateFnsLocale: 'fr' }, + he: { label: 'עברית', dateFnsLocale: 'he' }, + hr: { label: 'Hrvatski', dateFnsLocale: 'hr' }, + it: { label: 'Italiano', dateFnsLocale: 'it' }, + lt: { label: 'Lietuvių', dateFnsLocale: 'lt' }, + hu: { label: 'Magyar', dateFnsLocale: 'hu' }, + nl: { label: 'Nederlands', dateFnsLocale: 'nl' }, + no: { label: 'Norsk', dateFnsLocale: 'no' }, + pl: { label: 'Polski', dateFnsLocale: 'pl' }, 'pt-br': { label: 'Português (Brasil)', dateFnsLocale: 'ptBR' }, - 'ru': { label: 'Русский', dateFnsLocale: 'ru' }, - 'sv': { label: 'Svenska', dateFnsLocale: 'sv' }, - 'uk': { label: 'Українська', dateFnsLocale: 'uk' }, + ru: { label: 'Русский', dateFnsLocale: 'ru' }, + sv: { label: 'Svenska', dateFnsLocale: 'sv' }, + uk: { label: 'Українська', dateFnsLocale: 'uk' }, 'vi-vn': { label: 'Tiếng Việt', dateFnsLocale: 'vi' }, 'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'zhCN' }, 'zh-tw': { label: '正體中文 (Traditional Chinese)', dateFnsLocale: 'zhTW' } } -Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => { +Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map((code) => { return { text: languageCodeMap[code].label, value: code @@ -39,34 +40,34 @@ Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => { // iTunes search API uses ISO 3166 country codes: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 const podcastSearchRegionMap = { - 'br': { label: 'Brasil' }, - 'be': { label: 'België / Belgique / Belgien' }, - 'cz': { label: 'Česko' }, - 'dk': { label: 'Danmark' }, - 'de': { label: 'Deutschland' }, - 'ee': { label: 'Eesti' }, - 'es': { label: 'España / Espanya / Espainia' }, - 'fr': { label: 'France' }, - 'hr': { label: 'Hrvatska' }, - 'il': { label: 'ישראל / إسرائيل' }, - 'it': { label: 'Italia' }, - 'lu': { label: 'Luxembourg / Luxemburg / Lëtezebuerg' }, - 'hu': { label: 'Magyarország' }, - 'nl': { label: 'Nederland' }, - 'no': { label: 'Norge' }, - 'at': { label: 'Österreich' }, - 'pl': { label: 'Polska' }, - 'pt': { label: 'Portugal' }, - 'ru': { label: 'Россия' }, - 'ch': { label: 'Schweiz / Suisse / Svizzera' }, - 'se': { label: 'Sverige' }, - 'vn': { label: 'Việt Nam' }, - 'ua': { label: 'Україна' }, - 'gb': { label: 'United Kingdom' }, - 'us': { label: 'United States' }, - 'cn': { label: '中国' } + br: { label: 'Brasil' }, + be: { label: 'België / Belgique / Belgien' }, + cz: { label: 'Česko' }, + dk: { label: 'Danmark' }, + de: { label: 'Deutschland' }, + ee: { label: 'Eesti' }, + es: { label: 'España / Espanya / Espainia' }, + fr: { label: 'France' }, + hr: { label: 'Hrvatska' }, + il: { label: 'ישראל / إسرائيل' }, + it: { label: 'Italia' }, + lu: { label: 'Luxembourg / Luxemburg / Lëtezebuerg' }, + hu: { label: 'Magyarország' }, + nl: { label: 'Nederland' }, + no: { label: 'Norge' }, + at: { label: 'Österreich' }, + pl: { label: 'Polska' }, + pt: { label: 'Portugal' }, + ru: { label: 'Россия' }, + ch: { label: 'Schweiz / Suisse / Svizzera' }, + se: { label: 'Sverige' }, + vn: { label: 'Việt Nam' }, + ua: { label: 'Україна' }, + gb: { label: 'United Kingdom' }, + us: { label: 'United States' }, + cn: { label: '中国' } } -Vue.prototype.$podcastSearchRegionOptions = Object.keys(podcastSearchRegionMap).map(code => { +Vue.prototype.$podcastSearchRegionOptions = Object.keys(podcastSearchRegionMap).map((code) => { return { text: podcastSearchRegionMap[code].label, value: code @@ -85,9 +86,9 @@ Vue.prototype.$strings = { ...enUsStrings } /** * Get string and substitute - * - * @param {string} key - * @param {string[]} subs + * + * @param {string} key + * @param {string[]} subs * @returns {string} */ Vue.prototype.$getString = (key, subs) => { @@ -108,12 +109,14 @@ const translations = { function loadTranslationStrings(code) { return new Promise((resolve) => { - import(`../strings/${code}`).then((fileContents) => { - resolve(fileContents.default) - }).catch((error) => { - console.error('Failed to load i18n strings', code, error) - resolve(null) - }) + import(`../strings/${code}`) + .then((fileContents) => { + resolve(fileContents.default) + }) + .catch((error) => { + console.error('Failed to load i18n strings', code, error) + resolve(null) + }) }) } @@ -124,7 +127,7 @@ async function loadi18n(code) { return false } - const strings = translations[code] || await loadTranslationStrings(code) + const strings = translations[code] || (await loadTranslationStrings(code)) if (!strings) { console.warn(`Invalid lang code ${code}`) return false @@ -174,4 +177,3 @@ async function initialize() { } } initialize() -