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

[v9.8.0] Suppressing automatic locale fallback with ! breaks n/$n number formatting #1641

Open
4 tasks done
shengslogar opened this issue Nov 28, 2023 · 0 comments
Open
4 tasks done
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing Status: Proposal Request for comments Type: Feature Includes new features

Comments

@shengslogar
Copy link

Reporting a bug?

The docs describe adding an exclamation mark to locale to prevent vue-i18n from falling back to language parts when a regional/dialect match isn't found (e.g. en from en-US). While this is supported by the standard t/$t translator, it breaks the numeric n/$n formatter entirely, apparently due to passing the configured locale directly to new Intl.NumberFormat(locale, ...).

vue-i18n.js?v=01aa3a84:3153 Uncaught RangeError: Incorrect locale information provided
      at new NumberFormat (<anonymous>)
      at number (vue-i18n.js?v=01aa3a84:3153:12)
      at vue-i18n.js?v=01aa3a84:3825:46
      at wrapWithDeps (vue-i18n.js?v=01aa3a84:3773:13)
      at Proxy.n (vue-i18n.js?v=01aa3a84:3825:12)
      at Proxy._sfc_render (App.vue:9:6)
      at renderComponentRoot (chunk-FVTSMHLH.js?v=28e50421:2226:17)
      at ReactiveEffect.componentUpdateFn [as fn] (chunk-FVTSMHLH.js?v=28e50421:7162:46)
      at ReactiveEffect.run (chunk-FVTSMHLH.js?v=28e50421:422:19)
      at instance.update (chunk-FVTSMHLH.js?v=28e50421:7275:52)

Expected behavior

n/$n should behave the same as t/$t, and no error should occur.

Reproduction

https://stackblitz.com/edit/vitejs-vite-uyzmvt?file=src%2Fmain.ts,src%2FApp.vue

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.12 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /opt/homebrew/bin/node
    Yarn: 4.0.0 - /opt/homebrew/bin/yarn
    npm: 10.2.3 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 119.0.6045.159
    Safari: 17.1

Screenshot

No response

Additional context

No response

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing Status: Proposal Request for comments Type: Feature Includes new features
Projects
None yet
Development

No branches or pull requests

2 participants