From a909f54ff62dfb96695de89b0c8375669d4b7f51 Mon Sep 17 00:00:00 2001 From: kazupon Date: Thu, 31 Aug 2023 15:58:29 +0000 Subject: [PATCH 01/55] chore: generate changelog --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0e543e1..cf00ff8ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# v8.0.0-rc.4 (2023-08-31T15:58:24Z) + +This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-rc.4) + +###    🚀 Features + +- Pickup from unplugin-vue-i18n plugin options to nuxt i18n options  -  by @kazupon in https://github.com/nuxt-modules/i18n/issues/2323 [(fdf54)](https://github.com/nuxt-modules/i18n/commit/fdf54f4) +- Support bundle size tunning with `dropMessageCompiler` option  -  by @kazupon in https://github.com/nuxt-modules/i18n/issues/2352 [(417af)](https://github.com/nuxt-modules/i18n/commit/417af83) +- Disable caching for dynamic locale messages  -  by @BobbieGoede in https://github.com/nuxt-modules/i18n/issues/2355 [(3a621)](https://github.com/nuxt-modules/i18n/commit/3a62121) + +###    🐞 Bug Fixes + +- Drop `vueI18n` option warning  -  by @kazupon in https://github.com/nuxt-modules/i18n/issues/2324 [(d2223)](https://github.com/nuxt-modules/i18n/commit/d222364) +- Redirect status code "  -  by @wxh06 in https://github.com/nuxt-modules/i18n/issues/1861 and https://github.com/nuxt-modules/i18n/issues/2337 [(c276e)](https://github.com/nuxt-modules/i18n/commit/c276e64) +- Regression for API extending  -  by @kazupon in https://github.com/nuxt-modules/i18n/issues/2340 [(6c2a4)](https://github.com/nuxt-modules/i18n/commit/6c2a411) +- Loop redirection on 'ssr: false' and 'no_prefix' strategy  -  by @kazupon in https://github.com/nuxt-modules/i18n/issues/2341 [(f8692)](https://github.com/nuxt-modules/i18n/commit/f869292) +- Normalise `sourcemap` option to boolean  -  by @danielroe in https://github.com/nuxt-modules/i18n/issues/2344 [(cd9c3)](https://github.com/nuxt-modules/i18n/commit/cd9c3de) +- Lazy load locales  -  by @BobbieGoede in https://github.com/nuxt-modules/i18n/issues/2294 [(3a522)](https://github.com/nuxt-modules/i18n/commit/3a5226f) +- I18n layer vue i18n resolution  -  by @BobbieGoede in https://github.com/nuxt-modules/i18n/issues/2347 [(0ce01)](https://github.com/nuxt-modules/i18n/commit/0ce016a) + +#####     [View changes on GitHub](https://github.com/nuxt-modules/i18n/compare/v8.0.0-rc.3...v8.0.0-rc.4) + # v8.0.0-rc.3 (2023-08-16T10:16:01Z) This changelog is generated by [GitHub Releases](https://github.com/nuxt-modules/i18n/releases/tag/v8.0.0-rc.3) From bdc2991316cc09bc5343a35bf6b23ae2ce1bdd60 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Sun, 3 Sep 2023 10:30:32 +0200 Subject: [PATCH 02/55] fix: inline options edge channel (#2361) --- src/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2955da0a4..f99aba61a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -500,7 +500,10 @@ export function getHash(text: Buffer | string): string { export function getLayerI18n(configLayer: NuxtConfigLayer) { const layerInlineOptions = (configLayer.config.modules || []).find( - (mod): mod is [string, NuxtI18nOptions] | undefined => isArray(mod) && mod[0] === NUXT_I18N_MODULE_ID + (mod): mod is [string, NuxtI18nOptions] | undefined => + isArray(mod) && + typeof mod[0] === 'string' && + [NUXT_I18N_MODULE_ID, `${NUXT_I18N_MODULE_ID}-edge`].includes(mod[0]) )?.[1] if (configLayer.config.i18n) { From c41151860b41f99f18d026627d943c8170e9b9c8 Mon Sep 17 00:00:00 2001 From: Bobbie Goede Date: Mon, 4 Sep 2023 07:36:09 +0200 Subject: [PATCH 03/55] feat: layer vue i18n config merging (#2358) * feat: layer vue i18n config merging * test: update snapshot * fix: layer vuei18n configurations merge order * test: disable jit compilation for vuei18n layer test * docs: describe VueI18n option merging on layers page --- docs/content/2.guide/15.layers.md | 3 +- playground/layers/i18n-layer/i18n.config.ts | 15 ++- playground/locales/en.json | 14 ++- playground/pages/index.vue | 2 + playground/vue-i18n.options.ts | 7 +- specs/fixtures/layer_consumer/i18n.config.ts | 19 +++- .../layer-simple-secondary/i18n.config.ts | 15 +++ .../layer-simple-secondary/nuxt.config.ts | 10 ++ .../layer-simple/i18n.config.ts | 16 +++- .../layer-simple/nuxt.config.ts | 2 +- specs/fixtures/layer_consumer/nuxt.config.ts | 2 +- specs/fixtures/layer_consumer/pages/index.vue | 4 +- specs/layers/layers_vuei18n_options.spec.ts | 28 +++++- src/gen.ts | 91 ++++++++++--------- test/__snapshots__/gen.test.ts.snap | 58 +++++++----- 15 files changed, 207 insertions(+), 79 deletions(-) create mode 100644 specs/fixtures/layer_consumer/layer-simple-secondary/i18n.config.ts create mode 100644 specs/fixtures/layer_consumer/layer-simple-secondary/nuxt.config.ts diff --git a/docs/content/2.guide/15.layers.md b/docs/content/2.guide/15.layers.md index d5bff2323..418d677fb 100644 --- a/docs/content/2.guide/15.layers.md +++ b/docs/content/2.guide/15.layers.md @@ -13,7 +13,6 @@ Mixing locale configuration such as lazy loading objects and strings may not wor ## Pages & Routing - Pages in the `pages` directory from extended layers will automatically be merged and have i18n support as if they were part of your project. Page routes defined in `i18n.pages` in each layer configuration will be merged as well. @@ -114,3 +113,5 @@ This example would result in the project supporting two locales (`en`, `nl`) and :: :: +## VueI18n options +Options defined in VueI18n configuration files within layers are merged and override each other according to their layers priority. \ No newline at end of file diff --git a/playground/layers/i18n-layer/i18n.config.ts b/playground/layers/i18n-layer/i18n.config.ts index 9af6e6855..faf62091c 100644 --- a/playground/layers/i18n-layer/i18n.config.ts +++ b/playground/layers/i18n-layer/i18n.config.ts @@ -4,6 +4,19 @@ export default defineI18nConfig(() => { ja: { layerText: 'これはマージされたロケールキーです' } - } + }, + modifiers: { + // @ts-ignore + pascalCase: (str: string) => + str + .split(' ') + .map(s => s.slice(0, 1).toUpperCase() + s.slice(1)) + .join('') + }, + missingWarn: false, + fallbackWarn: false, + warnHtmlMessage: false, + silentFallbackWarn: true, + silentTranslationWarn: true } }) diff --git a/playground/locales/en.json b/playground/locales/en.json index 607877fdc..67d0ede31 100644 --- a/playground/locales/en.json +++ b/playground/locales/en.json @@ -8,8 +8,20 @@ "about": "About this site" } }, + "snakeCaseText": "@.snakeCase:{'pages.title.about'}", + "pascalCaseText": "@.pascalCase:{'pages.title.about'}", "welcome": "Welcome", "hello": "Hello {name} !", "tag": "

Tag

", - "items": [{ "name": "apple" }, { "name": "banana" }, { "name": "strabelly" }] + "items": [ + { + "name": "apple" + }, + { + "name": "banana" + }, + { + "name": "strawberry" + } + ] } diff --git a/playground/pages/index.vue b/playground/pages/index.vue index 17cb6be24..87ae2e098 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -69,6 +69,8 @@ definePageMeta({

Demo: Nuxt 3

{{ $t('hello', { name: 'nuxt3' }) }}

+

{{ $t('snakeCaseText') }}

+

{{ $t('pascalCaseText') }}

{{ $t('bar.buz', { name: 'buz' }) }}

Pages