[v9.8.0] Suppressing automatic locale fallback with `!` breaks `n`/`$n` number formatting
shengslogar opened this issue · comments
Sheng-Liang Slogar commented
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
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion
- The provided reproduction is a minimal reproducible example of the bug.
Sheng-Liang Slogar commented
Oops, moving to intlify/vue-i18n-next#1641