Skip to content

pluralRules configuration not applied when using lazy loading with defineI18nConfig #3903

@jozefvodicka

Description

@jozefvodicka

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

  1. 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
    ],
    },
    })

  2. 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
}))

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions