Skip to content

Commit 34b5250

Browse files
authored
fix!: deprecate options types, routesNameSeparator, defaultLocaleRouteNameSuffix (#3637)
1 parent cbb6f22 commit 34b5250

2 files changed

Lines changed: 60 additions & 32 deletions

File tree

docs/content/docs/02.guide/90.migrating.md

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,86 @@
11
---
22
title: Migration Guide
3-
description: Follow this guide to upgrade from one major version to the other.
3+
description: Follow this guide to upgrade from v9.x to v10.x
4+
toc:
5+
depth: 3
46
---
57

6-
## Upgrading from `nuxtjs/i18n` v9.x to v10.x
7-
88
### Upgrade to Vue I18n v11
99
We have upgrade from Vue I18n v10 to v11, this major version bump deprecates the Legacy API mode and custom `v-t` directive and drops `tc` and `$tc` from Legacy API mode.
1010

1111
Check the documentation detailing the breaking changes [here](https://vue-i18n.intlify.dev/guide/migration/breaking11.html).
1212

13-
### Lazy load locale messages by default and removed `lazy` option
13+
### Lazy loading
1414
The `lazy` option has been removed and lazy loading of locale messages is now the default behavior.
1515

16-
### Function signature corrected for `finalizePendingLocaleChange()`{lang="ts"}
16+
### `finalizePendingLocaleChange()`{lang="ts"} signature changed
1717
The function signature for `finalizePendingLocaleChange()`{lang="ts"} has been corrected from `() => Promise<void>`{lang="ts-type"} to `() => void`{lang="ts-type"}.
1818
This change was made since the function does not rely on any async operations and should not be awaited, and should prevent unnecessary function coloring.
1919

20-
### Option default changed `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"}
20+
### Default arguments changed `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"}
2121
The default value for the `key` property has been changed from `'hid'` to `'key'`.
2222

23-
### Deprecate `$localeHead()`{lang="ts"}
24-
The `$localeHead()`{lang="ts"} Nuxt context function has been deprecated and will be removed in v11.
23+
### `restructureDir` migration path removed
24+
To ease migration in v9 it was possible to disable the new directory structure by setting `restructureDir: false`, this has now been removed and we recommend using the default value of `'i18n'`.
25+
2526

26-
This context function has limited use cases, the `useLocaleHead` composable offers the same functionality and is easier to use in combination with `useHead`.
27+
### Removed options
28+
The following options have been removed:
2729

28-
### Deprecate `$getRouteBaseName()`{lang="ts"} in favor of `$routeBaseName()`{lang="ts"}
29-
The `$getRouteBaseName()`{lang="ts"} Nuxt context function has been deprecated and will be removed in v11.
30+
#### `bundle.optimizeTranslationDirective`{lang="yml"}
31+
* This feature has been disabled and the option to enable it has been removed, see [the discussion in this issue](https://github.com/nuxt-modules/i18n/issues/3238#issuecomment-2672492536) for context on this change.
3032

31-
We are renaming this function to `$routeBaseName()`{lang="ts"} to be consistent with the other context functions and their composable counterparts.
33+
#### `experimental.generatedLocaleFilePathFormat`{lang="yml"}
34+
* File paths (e.g. locale files, vue-i18n configs) configured for this module are now removed from the build entirely making this option obsolete.
3235

33-
### Promote `experimental.autoImportTranslationFunctions` to `autoDeclare`
34-
This functionality is stable and is now enabled by default, the option has been moved out of the `experimental` configuration object and renamed to `autoDeclare`.
3536

36-
### Promote `experimental.switchLocalePathLinkSSR`
37-
This functionality is stable and is now enabled by default and the option to enable/disable it has been removed.
37+
### Deprecated options
38+
The following options have been deprecated and will be removed in v11:
3839

39-
### Promote `experimental.hmr` to `hmr`
40-
The HMR functionality is stable, it was already enabled by default but to reflect its stability it has been moved out of the `experimental` configuration object.
40+
#### `types`{lang="yml"}
41+
* Only `'composition'` types will be supported in v11, in line with Vue I18n v12.
4142

42-
### Remove `restructureDir` migration path
43-
To ease migration in v9 it was possible to disable the new directory structure by setting `restructureDir: false`, this has now been removed and we recommend using the default value of `'i18n'`.
43+
#### `routesNameSeparator`{lang="yml"}
44+
* This was documented as internal, use cases for end-users are unclear.
45+
46+
#### `defaultLocaleRouteNameSuffix`{lang="yml"}
47+
* This was documented as internal, use cases for end-users are unclear.
48+
49+
50+
### Promoted options
51+
These options are stable and are now enabled by default, some have been renamed to better reflect their purpose.
4452

45-
### Dropped Nuxt context functions
53+
#### `experimental.hmr`{lang="yml"}
54+
* Now configurable with the `hmr` option
4655

56+
#### `experimental.switchLocalePathLinkSSR`{lang="yml"}
57+
* This is stable and the option to enable/disable it has been removed.
58+
59+
#### `experimental.autoImportTranslationFunctions`{lang="yml"}
60+
* Now configurable with the `autoDeclare` option
61+
62+
63+
### Dropped context functions
4764
The following functions have been removed from the Nuxt context.
48-
* `$resolveRoute()`{lang="ts"}
49-
* `$localeLocation()`{lang="ts"}
5065

51-
Steps to migrate
52-
* `$resolveRoute()`{lang="ts"} -> use `$localeRoute()` instead
53-
* `$localeLocation()`{lang="ts"} -> use `$localeRoute()` instead
66+
#### `$resolveRoute()`{lang="ts"}
67+
* Use `$localeRoute()`{lang="ts"} instead
68+
69+
#### `$localeLocation()`{lang="ts"}
70+
* Use `$localeRoute()`{lang="ts"} instead
71+
72+
73+
### Deprecated context functions
74+
These Nuxt context functions have been deprecated and will be removed in v11.
75+
76+
#### `$localeHead()`{lang="ts"}
77+
* Deprecated due to limited use cases, the `useLocaleHead` composable offers the same functionality and is easier to use in combination with `useHead`.
5478

55-
### Drop `bundle.optimizeTranslationDirective`
56-
This feature has been disabled and the option to enable it has been removed, see [the discussion in this issue](https://github.com/nuxt-modules/i18n/issues/3238#issuecomment-2672492536) for context on this change.
79+
#### `$getRouteBaseName()`{lang="ts"}
80+
* Deprecated in favor of the same function under a new name: `$routeBaseName()`{lang="ts"}, to be consistent with the other context functions and their composable counterparts.
5781

58-
### Drop `experimental.generatedLocaleFilePathFormat`
59-
File paths (e.g. locale files, vue-i18n configs) configured for this module are now removed entirely making this option obsolete.
6082

61-
### Removed exports from generated options files.
83+
## Generated options
6284
The generated options files in your projects are meant for internal use by this module at runtime and should never be used, more properties may be removed in the future.
6385

6486
The following exports have been removed from the generated options files (`#build/i18n.options.mjs` and `#internal/i18n/options.mjs`):
@@ -75,7 +97,7 @@ Reasons for removal:
7597
* These are no longer used by the module and might expose vulnerable information in the final build
7698
* Some options are now used as static values for better tree-shaking resulting in a smaller project build.
7799

78-
### Removed options from runtime config
100+
## Runtime config
79101
Several options set in the runtime config were only used to transfer build-time configuration to runtime and changing these at runtime could cause issues.
80102

81103
Instead of setting these on runtime config we now treat them as compiler constants, this way we can tree-shake any unused logic from a project build.

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ export type NuxtI18nOptions<
175175
i18nModules?: { langDir?: string | null; locales?: NuxtI18nOptions<Context>['locales'] }[]
176176
rootRedirect?: string | RootRedirectOptions
177177
skipSettingLocaleOnNavigate?: boolean
178+
/**
179+
* @deprecated This option is deprecated, only `'composition'` types will be supported in the future.
180+
* @default 'composition'
181+
*/
178182
types?: 'composition' | 'legacy'
179183
debug?: boolean | 'verbose'
180184
parallelPlugin?: boolean
@@ -211,13 +215,15 @@ export type NuxtI18nOptions<
211215
trailingSlash?: boolean
212216
/**
213217
* Internal separator used for generated route names for each locale - you shouldn't need to change this
218+
* @deprecated This option is deprecated and will be removed in the future.
214219
* @default '___'
215220
*/
216221
routesNameSeparator?: string
217222
/**
218223
* Internal suffix added to generated route names for default locale
219224
*
220225
* Relevant if strategy is `prefix_and_default` - you shouldn't need to change this.
226+
* @deprecated This option is deprecated and will be removed in the future.
221227
* @default 'default'
222228
*/
223229
defaultLocaleRouteNameSuffix?: string

0 commit comments

Comments
 (0)