API & Client - enable pl translations

This commit is contained in:
Sam
2023-06-24 19:14:02 +02:00
parent 8b60ca181f
commit b1c8a1c376
7 changed files with 21 additions and 21 deletions

View File

@ -6,18 +6,13 @@ import { createI18n, LocaleMessages, VueMessageType } from 'vue-i18n'
* The loaded `JSON` locale messages is pre-compiled by `@intlify/vue-i18n-loader`, which is integrated into `vue-cli-plugin-i18n`.
* See: https://github.com/intlify/vue-i18n-loader#rocket-i18n-resource-pre-compilation
*/
const disabledLanguages = ['pl'] // to update after translations release
function loadLocaleMessages(): Record<string, LocaleMessages<VueMessageType>> {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.ts$/i)
const messages: Record<string, LocaleMessages<VueMessageType>> = {}
locales.keys().forEach((key) => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
if (
matched &&
matched.length > 1 &&
!disabledLanguages.includes(matched[1])
) {
if (matched && matched.length > 1) {
const locale = matched[1]
messages[locale] = locales(key).default
}

View File

@ -100,7 +100,7 @@ export const dateStringFormats: Record<string, string> = {
fr: 'd MMM yyyy',
gl: 'd MMM yyyy',
it: 'd MMM yyyy',
// pl: 'd MMM yyyy', // disabled for now
pl: 'd MMM yyyy',
nb: 'do MMM yyyy',
nl: 'd MMM yyyy',
}

View File

@ -1,6 +1,6 @@
/* eslint-disable import/no-duplicates */
import { Locale } from 'date-fns'
import { de, enUS, es, fr, gl, it, nb, nl } from 'date-fns/locale'
import { de, enUS, es, fr, gl, it, nb, nl, pl } from 'date-fns/locale'
import createI18n from '@/i18n'
@ -11,7 +11,7 @@ export const localeFromLanguage: Record<string, Locale> = {
fr: fr,
gl: gl,
it: it,
// pl: pl,
pl: pl,
nb: nb,
nl: nl,
}
@ -22,10 +22,10 @@ export const languageLabels: Record<string, string> = {
es: 'Español',
fr: 'Français',
gl: 'Galego',
it: 'Italiano',
// pl: 'Polski',
nb: 'Norsk bokmål',
it: 'Italiano (87%)',
nb: 'Norsk bokmål (36%)',
nl: 'Nederlands',
pl: 'Polski (43%)',
}
const { availableLocales } = createI18n.global

View File

@ -2,9 +2,9 @@ import { zxcvbnOptions } from '@zxcvbn-ts/core'
export const loadLanguagePackage = async (language: string) => {
// no package available for
// - dutch (Nederlands)
// - galician
// - norwegian bokmal
// - Dutch (Nederlands)
// - Galician
// - Norwegian bokmal
// fallback to english
switch (language) {
case 'fr':
@ -23,11 +23,10 @@ export const loadLanguagePackage = async (language: string) => {
return await import(
/* webpackChunkName: "password.es" */ '@zxcvbn-ts/language-es-es'
)
// TODO: add package
// case 'pl':
// return await import(
// /* webpackChunkName: "password.pl" */ '@zxcvbn-ts/language-pl'
// )
case 'pl':
return await import(
/* webpackChunkName: "password.pl" */ '@zxcvbn-ts/language-pl'
)
default:
return await import(
/* webpackChunkName: "password.en" */ '@zxcvbn-ts/language-en'