kazupon / vue-i18n

:globe_with_meridians: Internationalization plugin for Vue.js

Home Page:https://kazupon.github.io/vue-i18n/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

shengslogar opened this issue · comments

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