Client - fix language select

This commit is contained in:
Sam 2022-11-01 17:16:45 +01:00
parent 6f7672e03e
commit 68913f2e25

View File

@ -6,12 +6,18 @@ 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`. * 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 * See: https://github.com/intlify/vue-i18n-loader#rocket-i18n-resource-pre-compilation
*/ */
const disabledLanguages = ['nb'] // to remove after norwegian translations release
function loadLocaleMessages(): Record<string, LocaleMessages<VueMessageType>> { function loadLocaleMessages(): Record<string, LocaleMessages<VueMessageType>> {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.ts$/i) const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.ts$/i)
const messages: Record<string, LocaleMessages<VueMessageType>> = {} const messages: Record<string, LocaleMessages<VueMessageType>> = {}
locales.keys().forEach((key) => { locales.keys().forEach((key) => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i) const matched = key.match(/([A-Za-z0-9-_]+)\./i)
if (matched && matched.length > 1) { if (
matched &&
matched.length > 1 &&
!disabledLanguages.includes(matched[1])
) {
const locale = matched[1] const locale = matched[1]
messages[locale] = locales(key).default messages[locale] = locales(key).default
} }