mirror of
https://github.com/elk-zone/elk
synced 2024-12-03 01:08:07 +09:00
chore: use latest i18n v9 (#3059)
This commit is contained in:
parent
e6ebde3ac4
commit
f4b667fef6
@ -90,7 +90,7 @@ We've added some `UnoCSS` utilities styles to help you with that:
|
|||||||
|
|
||||||
## Internationalization
|
## Internationalization
|
||||||
|
|
||||||
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://v8.i18n.nuxtjs.org/) to handle internationalization.
|
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://i18n.nuxtjs.org/) to handle internationalization.
|
||||||
|
|
||||||
You can check the current [translation status](https://docs.elk.zone/docs/guide/contributing#translation-status): more instructions on the table caption.
|
You can check the current [translation status](https://docs.elk.zone/docs/guide/contributing#translation-status): more instructions on the table caption.
|
||||||
|
|
||||||
|
@ -75,11 +75,13 @@ export const countryLocaleVariants: Record<string, (LocaleObjectData & { country
|
|||||||
|
|
||||||
const locales: LocaleObjectData[] = [
|
const locales: LocaleObjectData[] = [
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error en used as placeholder
|
||||||
code: 'en',
|
code: 'en',
|
||||||
file: 'en.json',
|
file: 'en.json',
|
||||||
name: 'English',
|
name: 'English',
|
||||||
},
|
},
|
||||||
({
|
({
|
||||||
|
// @ts-expect-error ar used as placeholder
|
||||||
code: 'ar',
|
code: 'ar',
|
||||||
file: 'ar.json',
|
file: 'ar.json',
|
||||||
name: 'العربية',
|
name: 'العربية',
|
||||||
@ -110,6 +112,7 @@ const locales: LocaleObjectData[] = [
|
|||||||
},
|
},
|
||||||
} satisfies LocaleObjectData),
|
} satisfies LocaleObjectData),
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error ca used as placeholder
|
||||||
code: 'ca',
|
code: 'ca',
|
||||||
file: 'ca.json',
|
file: 'ca.json',
|
||||||
name: 'Català',
|
name: 'Català',
|
||||||
@ -150,6 +153,7 @@ const locales: LocaleObjectData[] = [
|
|||||||
name: 'Nederlands',
|
name: 'Nederlands',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error es used as placeholder
|
||||||
code: 'es',
|
code: 'es',
|
||||||
file: 'es.json',
|
file: 'es.json',
|
||||||
name: 'Español',
|
name: 'Español',
|
||||||
@ -203,6 +207,7 @@ const locales: LocaleObjectData[] = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// @ts-expect-error pt used as placeholder
|
||||||
code: 'pt',
|
code: 'pt',
|
||||||
file: 'pt.json',
|
file: 'pt.json',
|
||||||
name: 'Português',
|
name: 'Português',
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
publish = "dist"
|
publish = "dist"
|
||||||
command = "pnpm run build"
|
command = "pnpm run build"
|
||||||
|
|
||||||
|
[build.environment]
|
||||||
|
NODE_OPTIONS = '--max-old-space-size=4096'
|
||||||
|
|
||||||
# Redirect to Discord server
|
# Redirect to Discord server
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "https://chat.elk.zone"
|
from = "https://chat.elk.zone"
|
||||||
|
@ -311,8 +311,12 @@ export default defineNuxtConfig({
|
|||||||
lazy: true,
|
lazy: true,
|
||||||
strategy: 'no_prefix',
|
strategy: 'no_prefix',
|
||||||
detectBrowserLanguage: false,
|
detectBrowserLanguage: false,
|
||||||
langDir: 'locales',
|
// relative to i18n dir on rootDir: not yet v4 compat layout
|
||||||
|
langDir: '../locales',
|
||||||
defaultLocale: 'en-US',
|
defaultLocale: 'en-US',
|
||||||
|
experimental: {
|
||||||
|
generatedLocaleFilePathFormat: 'relative',
|
||||||
|
},
|
||||||
vueI18n: './config/i18n.config.ts',
|
vueI18n: './config/i18n.config.ts',
|
||||||
},
|
},
|
||||||
pwa,
|
pwa,
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
"@nuxt/devtools": "^1.5.2",
|
"@nuxt/devtools": "^1.5.2",
|
||||||
"@nuxt/test-utils": "^3.14.3",
|
"@nuxt/test-utils": "^3.14.3",
|
||||||
"@nuxtjs/color-mode": "^3.4.4",
|
"@nuxtjs/color-mode": "^3.4.4",
|
||||||
"@nuxtjs/i18n": "^8.5.3",
|
"@nuxtjs/i18n": "^9.1.0",
|
||||||
"@pinia/nuxt": "^0.5.4",
|
"@pinia/nuxt": "^0.5.4",
|
||||||
"@tiptap/core": "2.2.4",
|
"@tiptap/core": "2.2.4",
|
||||||
"@tiptap/extension-bold": "2.2.4",
|
"@tiptap/extension-bold": "2.2.4",
|
||||||
@ -146,9 +146,8 @@
|
|||||||
"pnpm": {
|
"pnpm": {
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"pinceau": "patches/pinceau.patch",
|
"pinceau": "patches/pinceau.patch",
|
||||||
"vue-i18n": "patches/vue-i18n.patch",
|
|
||||||
"nuxt-security": "patches/nuxt-security.patch",
|
"nuxt-security": "patches/nuxt-security.patch",
|
||||||
"nuxt": "patches/nuxt.patch"
|
"@nuxtjs/i18n@9.1.0": "patches/@nuxtjs__i18n@9.1.0.patch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
13
patches/@nuxtjs__i18n@9.1.0.patch
Normal file
13
patches/@nuxtjs__i18n@9.1.0.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/dist/module.mjs b/dist/module.mjs
|
||||||
|
index b6def32f8bde5516e6ee0a25f153b01803f55683..897b44120533fdb74b33d9d4dff1d21b910073ca 100644
|
||||||
|
--- a/dist/module.mjs
|
||||||
|
+++ b/dist/module.mjs
|
||||||
|
@@ -1462,7 +1462,7 @@ async function extendBundler({ options: nuxtOptions }, nuxt) {
|
||||||
|
fullInstall: nuxtOptions.bundle.fullInstall,
|
||||||
|
onlyLocales: nuxtOptions.bundle.onlyLocales,
|
||||||
|
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
|
||||||
|
- optimizeTranslationDirective: true,
|
||||||
|
+ optimizeTranslationDirective: false,
|
||||||
|
strictMessage: nuxtOptions.compilation.strictMessage,
|
||||||
|
escapeHtml: nuxtOptions.compilation.escapeHtml,
|
||||||
|
defaultSFCLang: nuxtOptions.customBlocks.defaultSFCLang,
|
@ -1,12 +0,0 @@
|
|||||||
diff --git a/dist/index.mjs b/dist/index.mjs
|
|
||||||
index a5c61adc0c21b5df5b1a3ffcf81d2469c7f96873..9241cf294b398b43a4a5555f39746a6c844d0b0f 100644
|
|
||||||
--- a/dist/index.mjs
|
|
||||||
+++ b/dist/index.mjs
|
|
||||||
@@ -2183,6 +2183,7 @@ function createTransformPlugin(nuxt, getComponents, mode) {
|
|
||||||
}
|
|
||||||
return createUnplugin(() => ({
|
|
||||||
name: "nuxt:components:imports",
|
|
||||||
+ enforce: "post",
|
|
||||||
transformInclude(id) {
|
|
||||||
id = normalize(id);
|
|
||||||
return id.startsWith("virtual:") || id.startsWith("\0virtual:") || id.startsWith(nuxt.options.buildDir) || !isIgnored(id);
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/dist/vue-i18n.d.ts b/dist/vue-i18n.d.ts
|
|
||||||
index 8d5c4fc0e551ab3beccfcaa67764818a2c4c6756..0cee95f214e03add239d3df5e91ad2a8a154ac1e 100644
|
|
||||||
--- a/dist/vue-i18n.d.ts
|
|
||||||
+++ b/dist/vue-i18n.d.ts
|
|
||||||
@@ -3125,7 +3125,7 @@ export declare type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error';
|
|
||||||
|
|
||||||
export { }
|
|
||||||
|
|
||||||
-declare module '@vue/runtime-core' {
|
|
||||||
+declare module 'vue' {
|
|
||||||
/**
|
|
||||||
* Component Custom Options for Vue I18n
|
|
||||||
*
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { Locale } from '#i18n'
|
||||||
|
|
||||||
export default defineNuxtPlugin(async (nuxt) => {
|
export default defineNuxtPlugin(async (nuxt) => {
|
||||||
const t = nuxt.vueApp.config.globalProperties.$t
|
const t = nuxt.vueApp.config.globalProperties.$t
|
||||||
const d = nuxt.vueApp.config.globalProperties.$d
|
const d = nuxt.vueApp.config.globalProperties.$d
|
||||||
@ -11,14 +13,14 @@ export default defineNuxtPlugin(async (nuxt) => {
|
|||||||
const i18n = useNuxtApp().$i18n
|
const i18n = useNuxtApp().$i18n
|
||||||
const { setLocale, locales } = i18n
|
const { setLocale, locales } = i18n
|
||||||
const userSettings = useUserSettings()
|
const userSettings = useUserSettings()
|
||||||
const lang = computed(() => userSettings.value.language)
|
const lang = computed(() => userSettings.value.language as Locale)
|
||||||
|
|
||||||
const supportLanguages = unref(locales).map(locale => locale.code)
|
const supportLanguages = unref(locales).map(locale => locale.code)
|
||||||
if (!supportLanguages.includes(lang.value))
|
if (!supportLanguages.includes(lang.value))
|
||||||
userSettings.value.language = getDefaultLanguage(supportLanguages)
|
userSettings.value.language = getDefaultLanguage(supportLanguages)
|
||||||
|
|
||||||
if (lang.value !== i18n.locale)
|
if (lang.value !== i18n.locale)
|
||||||
await setLocale(userSettings.value.language)
|
await setLocale(userSettings.value.language as Locale)
|
||||||
|
|
||||||
watch([lang, isHydrated], () => {
|
watch([lang, isHydrated], () => {
|
||||||
if (isHydrated.value && lang.value !== i18n.locale)
|
if (isHydrated.value && lang.value !== i18n.locale)
|
||||||
|
580
pnpm-lock.yaml
580
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user