Add:Finnish language option

This commit is contained in:
advplyr 2024-06-16 09:42:40 -05:00
parent 516a3858c5
commit a75ad5d659

View File

@ -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()