Skip to content

Implicit {n} only support Number, and not String #2147

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

Open
4 tasks done
mrleblanc101 opened this issue Mar 27, 2025 · 1 comment
Open
4 tasks done

Implicit {n} only support Number, and not String #2147

mrleblanc101 opened this issue Mar 27, 2025 · 1 comment
Labels
Status: Proposal Request for comments

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Mar 27, 2025

Reporting a bug?

Not sure if this is a bug, or a feature request.

Since $tc has been deprecated, there is very little difference between Message Format Syntax and Plurialization.

In Message Format Syntax, you can use Named interpolation ({count}) and List Interpolation ({0}), but not Implicit Interpolation. Implicit Interpolation ({n}) can only be used with Plurizalization.

Techncally, you can use Implicit Interpolation ({n}) without Plurizalization, but only if n is a Number, not if it's a String.

Input: 
<div>{{ t('Test {n}', 1) }}</div>
Output: "Test 1"
Input: 
<div>{{ t('Test {n}', "1") }}</div> 
Output: "1"

Maybe there is a good reason for it, and I don't see it, or maybe Message Format could be made to support Implicit Interpolation ({n}) with a String.

Expected behavior

Input: 
<div>{{ t('Test {n}', "1") }}</div> 
Output: "Test 1"

Reproduction

https://stackblitz.com/edit/vitejs-vite-saeaemxg?file=src%2FApp.vue

System Info

System:
    OS: macOS 15.3.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 72.06 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
  Browsers:
    Chrome: 134.0.6998.166
    Chrome Canary: 136.0.7093.0
    Edge: 134.0.3124.85
    Safari: 18.3
    Safari Technology Preview: 18.4
  npmPackages:
    vue: latest => 3.5.13

Screenshot

Image

Additional context

No response

Validations

@mrleblanc101 mrleblanc101 added the Status: Review Needed Request for review comments label Mar 27, 2025
@mrleblanc101
Copy link
Author

Technically, I could just change to:
List Interpolation: {{ t('Test {0}', ["1"]) }}
Named Interpolation: {{ t('Test {count}', { count: "1" }) }}

But where this is a single argument, I prefer not using List or Named Interpolation.

@mrleblanc101 mrleblanc101 mentioned this issue Mar 29, 2025
11 tasks
@kazupon kazupon added Status: Proposal Request for comments and removed Status: Review Needed Request for review comments labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

2 participants