Environment
Nuxt project info:
|
|
| Operating system |
Linux 6.17.8-orbstack-00308-g8f9c941121b1 |
| CPU |
unknown (8 cores) |
| Node.js version |
v24.12.0 |
| nuxt/cli version |
3.31.3 |
| Package manager |
yarn@4.10.3 |
| Nuxt version |
4.2.2 |
| Nitro version |
2.12.9 |
| Builder |
vite@7.3.0 |
| Config |
- |
| Modules |
- |
Reproduction
Steps to Reproduce
-
Configure Nuxt i18n with lazy loading:
// nuxt.config.ts
export default defineNuxtConfig({
i18n: {
vueI18n: './i18n/i18n.config.ts',
defaultLocale: 'en',
strategy: 'no_prefix',
langDir: 'locales/',
locales: [
{
code: 'cs',
file: 'cs.ts',
},
// ... other locales
],
},
})
-
Define custom pluralRules in i18n.config.ts:
// i18n.config.ts
import { pluralRules } from '@shared/locales'
export default defineI18nConfig(() => ({
legacy: false,
pluralRules, // This should be applied but isn't
}))
- Check runtime i18n instance:
// In browser console
const i18n = useNuxtApp().$i18n
console.log(i18n.pluralRules) // Returns: {} (empty object)## Environment
- @nuxtjs/i18n version: 10.x (tested with current version)
- Nuxt version: 4.x
- Vue I18n version: 11.x (peer dependency)
- Lazy loading: enabled (
langDir and file options)
Additional Context
- The
pluralRules functions are correctly defined and exported
- The issue occurs specifically with lazy loading - when lazy loading is disabled, the pluralization might work correctly
- Workaround implemented: Created a custom composable that manually handles pluralization by accessing raw translation messages and selecting the correct form
- The bug affects languages with complex pluralization rules like Czech, Slovak, Polish, etc.
Impact
This prevents proper internationalization for applications that need custom pluralization rules, particularly affecting Slavic languages that have more than the standard 2-3 plural forms.
Describe the bug
Bug Report: pluralRules configuration not applied when using lazy loading with defineI18nConfig
Description
When using @nuxtjs/i18n with lazy loading and defineI18nConfig, custom pluralRules functions defined in the configuration are not being applied to the runtime Vue I18n instance. This causes the application to fall back to default pluralization rules instead of using the custom pluralization logic.
Expected Behavior
Custom pluralRules defined in i18n.config.ts should be applied to the Vue I18n instance, allowing proper pluralization for languages with complex plural forms (like Czech and Slovak with their 4 plural forms: zero, singular, few, many).
Actual Behavior
The runtime Vue I18n instance shows pluralRules: {} (empty object), and default pluralization rules are used instead of the custom ones.
Additional context
No response
Logs
Environment
Nuxt project info:
Linux 6.17.8-orbstack-00308-g8f9c941121b1unknown (8 cores)v24.12.03.31.3yarn@4.10.34.2.22.12.9vite@7.3.0--Reproduction
Steps to Reproduce
Configure Nuxt i18n with lazy loading:
// nuxt.config.ts
export default defineNuxtConfig({
i18n: {
vueI18n: './i18n/i18n.config.ts',
defaultLocale: 'en',
strategy: 'no_prefix',
langDir: 'locales/',
locales: [
{
code: 'cs',
file: 'cs.ts',
},
// ... other locales
],
},
})
Define custom
pluralRulesini18n.config.ts:// i18n.config.ts
import { pluralRules } from '@shared/locales'
export default defineI18nConfig(() => ({
legacy: false,
pluralRules, // This should be applied but isn't
}))
// In browser console
const i18n = useNuxtApp().$i18n
console.log(i18n.pluralRules) // Returns: {} (empty object)## Environment
langDirandfileoptions)Additional Context
pluralRulesfunctions are correctly defined and exportedImpact
This prevents proper internationalization for applications that need custom pluralization rules, particularly affecting Slavic languages that have more than the standard 2-3 plural forms.
Describe the bug
Bug Report:
pluralRulesconfiguration not applied when using lazy loading withdefineI18nConfigDescription
When using
@nuxtjs/i18nwith lazy loading anddefineI18nConfig, custompluralRulesfunctions defined in the configuration are not being applied to the runtime Vue I18n instance. This causes the application to fall back to default pluralization rules instead of using the custom pluralization logic.Expected Behavior
Custom
pluralRulesdefined ini18n.config.tsshould be applied to the Vue I18n instance, allowing proper pluralization for languages with complex plural forms (like Czech and Slovak with their 4 plural forms: zero, singular, few, many).Actual Behavior
The runtime Vue I18n instance shows
pluralRules: {}(empty object), and default pluralization rules are used instead of the custom ones.Additional context
No response
Logs