Skip to content

Commit f4b667f

Browse files
authored
chore: use latest i18n v9 (#3059)
1 parent e6ebde3 commit f4b667f

10 files changed

+312
-331
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ We've added some `UnoCSS` utilities styles to help you with that:
9090

9191
## Internationalization
9292

93-
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://v8.i18n.nuxtjs.org/) to handle internationalization.
93+
We are using [vue-i18n](https://vue-i18n.intlify.dev/) via [nuxt-i18n](https://i18n.nuxtjs.org/) to handle internationalization.
9494

9595
You can check the current [translation status](https://docs.elk.zone/docs/guide/contributing#translation-status): more instructions on the table caption.
9696

config/i18n.ts

+5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ export const countryLocaleVariants: Record<string, (LocaleObjectData & { country
7575

7676
const locales: LocaleObjectData[] = [
7777
{
78+
// @ts-expect-error en used as placeholder
7879
code: 'en',
7980
file: 'en.json',
8081
name: 'English',
8182
},
8283
({
84+
// @ts-expect-error ar used as placeholder
8385
code: 'ar',
8486
file: 'ar.json',
8587
name: 'العربية',
@@ -110,6 +112,7 @@ const locales: LocaleObjectData[] = [
110112
},
111113
} satisfies LocaleObjectData),
112114
{
115+
// @ts-expect-error ca used as placeholder
113116
code: 'ca',
114117
file: 'ca.json',
115118
name: 'Català',
@@ -150,6 +153,7 @@ const locales: LocaleObjectData[] = [
150153
name: 'Nederlands',
151154
},
152155
{
156+
// @ts-expect-error es used as placeholder
153157
code: 'es',
154158
file: 'es.json',
155159
name: 'Español',
@@ -203,6 +207,7 @@ const locales: LocaleObjectData[] = [
203207
},
204208
},
205209
{
210+
// @ts-expect-error pt used as placeholder
206211
code: 'pt',
207212
file: 'pt.json',
208213
name: 'Português',

netlify.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
publish = "dist"
33
command = "pnpm run build"
44

5+
[build.environment]
6+
NODE_OPTIONS = '--max-old-space-size=4096'
7+
58
# Redirect to Discord server
69
[[redirects]]
710
from = "https://chat.elk.zone"

nuxt.config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,12 @@ export default defineNuxtConfig({
311311
lazy: true,
312312
strategy: 'no_prefix',
313313
detectBrowserLanguage: false,
314-
langDir: 'locales',
314+
// relative to i18n dir on rootDir: not yet v4 compat layout
315+
langDir: '../locales',
315316
defaultLocale: 'en-US',
317+
experimental: {
318+
generatedLocaleFilePathFormat: 'relative',
319+
},
316320
vueI18n: './config/i18n.config.ts',
317321
},
318322
pwa,

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@nuxt/devtools": "^1.5.2",
4141
"@nuxt/test-utils": "^3.14.3",
4242
"@nuxtjs/color-mode": "^3.4.4",
43-
"@nuxtjs/i18n": "^8.5.3",
43+
"@nuxtjs/i18n": "^9.1.0",
4444
"@pinia/nuxt": "^0.5.4",
4545
"@tiptap/core": "2.2.4",
4646
"@tiptap/extension-bold": "2.2.4",
@@ -146,9 +146,8 @@
146146
"pnpm": {
147147
"patchedDependencies": {
148148
"pinceau": "patches/pinceau.patch",
149-
"vue-i18n": "patches/vue-i18n.patch",
150149
"nuxt-security": "patches/nuxt-security.patch",
151-
"nuxt": "patches/nuxt.patch"
150+
"@nuxtjs/[email protected]": "patches/@[email protected].patch"
152151
}
153152
},
154153
"resolutions": {

patches/@[email protected]

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dist/module.mjs b/dist/module.mjs
2+
index b6def32f8bde5516e6ee0a25f153b01803f55683..897b44120533fdb74b33d9d4dff1d21b910073ca 100644
3+
--- a/dist/module.mjs
4+
+++ b/dist/module.mjs
5+
@@ -1462,7 +1462,7 @@ async function extendBundler({ options: nuxtOptions }, nuxt) {
6+
fullInstall: nuxtOptions.bundle.fullInstall,
7+
onlyLocales: nuxtOptions.bundle.onlyLocales,
8+
dropMessageCompiler: nuxtOptions.bundle.dropMessageCompiler,
9+
- optimizeTranslationDirective: true,
10+
+ optimizeTranslationDirective: false,
11+
strictMessage: nuxtOptions.compilation.strictMessage,
12+
escapeHtml: nuxtOptions.compilation.escapeHtml,
13+
defaultSFCLang: nuxtOptions.customBlocks.defaultSFCLang,

patches/nuxt.patch

-12
This file was deleted.

patches/vue-i18n.patch

-13
This file was deleted.

plugins/setup-i18n.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Locale } from '#i18n'
2+
13
export default defineNuxtPlugin(async (nuxt) => {
24
const t = nuxt.vueApp.config.globalProperties.$t
35
const d = nuxt.vueApp.config.globalProperties.$d
@@ -11,14 +13,14 @@ export default defineNuxtPlugin(async (nuxt) => {
1113
const i18n = useNuxtApp().$i18n
1214
const { setLocale, locales } = i18n
1315
const userSettings = useUserSettings()
14-
const lang = computed(() => userSettings.value.language)
16+
const lang = computed(() => userSettings.value.language as Locale)
1517

1618
const supportLanguages = unref(locales).map(locale => locale.code)
1719
if (!supportLanguages.includes(lang.value))
1820
userSettings.value.language = getDefaultLanguage(supportLanguages)
1921

2022
if (lang.value !== i18n.locale)
21-
await setLocale(userSettings.value.language)
23+
await setLocale(userSettings.value.language as Locale)
2224

2325
watch([lang, isHydrated], () => {
2426
if (isHydrated.value && lang.value !== i18n.locale)

0 commit comments

Comments
 (0)