-
-
Notifications
You must be signed in to change notification settings - Fork 518
Description
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 | [email protected] |
| Nuxt version | 4.2.2 |
| Nitro version | 2.12.9 |
| Builder | [email protected] |
| 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
pluralRulesini18n.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 (
langDirandfileoptions)
Additional Context
- The
pluralRulesfunctions 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