Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric named parameter overwrites plural parameter in pluralization #2120

Open
4 tasks done
netpok opened this issue Feb 20, 2025 · 0 comments
Open
4 tasks done

Numeric named parameter overwrites plural parameter in pluralization #2120

netpok opened this issue Feb 20, 2025 · 0 comments
Labels
Status: Review Needed Request for review comments

Comments

@netpok
Copy link

netpok commented Feb 20, 2025

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

@netpok netpok added the Status: Review Needed Request for review comments label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

1 participant