You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/module-options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ Where translation files live and how keys are resolved.
60
60
|`translationDir`|`string`|`'locales'`| Path to the directory containing translation JSON files, relative to the project root. |
61
61
|`disableWatcher`|`boolean`|`false`| Disable the file watcher that auto-creates missing translation files in development mode. |
62
62
|`routesLocaleLinks`|`{ [key: string]: string }`|`{}`| Map route names to other route names to share the same translation files. For example, `{ 'about-us': 'about' }` means the `about-us` page will use translations from the `about` page instead of its own. |
63
-
|`plural`|`string \| PluralFunc`|`built-in pluralization (singular/plural by count)`| Custom pluralization function or a path to a file exporting one. When a string path is provided, the file is imported at build time. The function receives `(key, count, params, locale, getter)` and should return the correct plural form as a string, or `null` to fall back to the built-in logic. |
63
+
|`plural`|`PluralFunc`|`built-in pluralization (form index by count)`| Custom pluralization function. Receives `(key, count, params, locale, getter)` and should return the selected plural form as a string, or `null`/`undefined` to fall back to the built-in `defaultPlural`logic (so you can override only some locales). For the Nuxt module the function is serialized with `.toString()` into `.nuxt/i18n.plural.mjs` — it must be self-contained (no imports / outer scope). A file path string is **not** supported. |
64
64
|`disablePageLocales`|`boolean`|`false`| Disable per-page translation files. When `true`, only global translations (`{locale}.json`) are loaded; page-specific files (`pages/{page}/{locale}.json`) are not generated or loaded. |
65
65
|`fallbackLocale`|`string`|`undefined (no fallback; returns the raw key)`| Global fallback locale code. When a translation key is missing in the active locale, the module looks it up in this locale before returning the key itself. |
Copy file name to clipboardExpand all lines: docs/guide/configuration.md
+35-27Lines changed: 35 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ The sections below explain how they work together; the
50
50
|[`disableWatcher`](/api/module-options)|`boolean`|`false`| Disable the file watcher that auto-creates missing translation files in development mode. |
51
51
|[`types`](/api/module-options)|`boolean`|`true`| Generate TypeScript type declarations for `useI18n`, `$t`, and related helpers based on the translation keys in your default locale files. |
52
52
|[`routesLocaleLinks`](/api/module-options)|`{ [key: string]: string }`|`{}`| Map route names to other route names to share the same translation files. |
53
-
|[`plural`](/api/module-options)|`string \| PluralFunc`|`built-in pluralization (singular/plural by count)`| Custom pluralization function or a path to a file exporting one. |
53
+
|[`plural`](/api/module-options)|`PluralFunc`|`built-in pluralization (form index by count)`| Custom pluralization function. |
|[`fallbackLocale`](/api/module-options)|`string`|`undefined (no fallback; returns the raw key)`| Global fallback locale code. |
56
56
|[`localeCookie`](/api/module-options)|`string \| null`|`null`| Cookie name for persisting the user's locale preference across sessions. |
@@ -640,12 +640,16 @@ autoDetectPath: '*' // On all routes (use with caution)
640
640
641
641
<!-- generated:option:plural — do not edit; run `pnpm run docs:generate` -->
642
642
643
-
**Type**`string \| PluralFunc` · **Default**`built-in pluralization (singular/plural by count)`
643
+
**Type**`PluralFunc` · **Default**`built-in pluralization (form index by count)`
644
644
645
-
Custom pluralization function or a path to a file exporting one.
646
-
When a string path is provided, the file is imported at build time.
647
-
The function receives `(key, count, params, locale, getter)` and should return
648
-
the correct plural form as a string, or `null` to fall back to the built-in logic.
645
+
Custom pluralization function.
646
+
Receives `(key, count, params, locale, getter)` and should return the selected
647
+
plural form as a string, or `null`/`undefined` to fall back to the built-in
648
+
`defaultPlural` logic (so you can override only some locales).
649
+
650
+
For the Nuxt module the function is serialized with `.toString()` into
651
+
`.nuxt/i18n.plural.mjs` — it must be self-contained (no imports / outer scope).
652
+
A file path string is **not** supported.
649
653
650
654
<!-- /generated:option:plural -->
651
655
@@ -678,8 +682,9 @@ For languages with complex pluralization rules (e.g., Russian, Arabic, Polish),
678
682
The function is serialized via `.toString()` and injected into a virtual module at build time. This means:
679
683
680
684
-**Must use `function` keyword** — NOT shorthand method syntax, NOT arrow functions with external references
681
-
-**No imports or external references** — the function must be fully self-contained
685
+
-**No imports or external references** — the function must be fully self-contained (a file path like `plural: '~/i18n/plural.ts'` is **not** supported)
682
686
-**No TypeScript-only syntax** that doesn't survive `.toString()` (type annotations are fine in `nuxt.config.ts` because Nuxt strips them)
687
+
- Returning `null` / `undefined` falls back to the built-in `defaultPlural` (useful for per-locale overrides)
Copy file name to clipboardExpand all lines: docs/news/index.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,12 @@ outline: 'deep'
6
6
7
7
# News
8
8
9
+
## Unreleased — custom `plural` falls back to default (#241)
10
+
11
+
**Date**: 2026-07-31
12
+
13
+
A custom `plural` that returns `null`/`undefined` now chains to the built-in `defaultPlural`, so you can override only some locales (e.g. Slavic) without reimplementing English-style rules. File-path `plural: '~/…'` is **not** supported — the function must stay self-contained in `nuxt.config` (serialized via `.toString()`).
14
+
9
15
## Unreleased — hreflang from `iso`, not routing `code` (#243)
0 commit comments