Skip to content

Numeric named parameter overwrites plural parameter in pluralization #2120

@netpok

Description

@netpok

Reporting a bug?

When using the following code a numeric named parameter overwrites the plural parameter:

t('Test', plural, { named: {n: namedValue}})

It looks like somewhere the following happens:

if (named.n is number) {
  plural = named.n
}

Expected behavior

When the Test translation key is set to one|{n} the following is expected/happens:

plural namedValue expected current output
1 1 one ✅ one
2 2 2 ✅ 2
1 2 one ❌ 2
2 1 1 ❌ one
1 string one ✅ one
2 string string ✅ string

Reproduction

If the table above is not enough I will create a repo.

System Info

System:
    OS: Linux 6.8 Linux Mint 21.3 (Virginia)
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
    Memory: 12.47 GB / 30.18 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.18.3 - /usr/bin/node
    Yarn: 1.16.0 - /usr/bin/yarn
    npm: 10.8.2 - /usr/bin/npm
  Browsers:
    Chrome: 133.0.6943.98
    Chromium: 133.0.6943.53
  npmPackages:
    @intlify/eslint-plugin-vue-i18n: ^3.0.0 => 3.2.0 
    @vitejs/plugin-vue: ^5.0.3 => 5.2.1 
    vite: ^6.1.0 => 6.1.1 
    vite-bundle-visualizer: ^1.1.0 => 1.2.1 
    vite-plugin-static-copy: ^2.2.0 => 2.2.0 
    vue: ^3.5.12 => 3.5.13 
    vue-i18n: ^11.1.0 => 11.1.1

Screenshot

No response

Additional context

In my opinion the n and plural variables should not be used for different things but I still consider this as bug.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions