intlify / vue-i18n

Vue I18n for Vue 3

Home Page:https://vue-i18n.intlify.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fallback locale deep key using `tm` throw error

everyx opened this issue · comments

Reporting a bug?

When a deep not exist current locale, but exist in fallback locale, it will throw error Cannot read properties of null (reading 'xxx')

Expected behavior

Use the value from the fallback locale

Reproduction

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

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^4.2.3 => 4.3.4 
    vite: ^4.4.9 => 4.4.9 
    vue: ^3.3.4 => 3.3.4 
    vue-i18n: ^9.3.0 => 9.3.0 
    vue-tsc: ^1.8.8 => 1.8.10

Screenshot

No response

Additional context

No response

Validations

Unfortunately, vue-i18n expects the message retrieved by tm to be an array, and the use case expectation is to resolve it using rt.
It also expects the messages retrieved in the array to have the same structure in this case en and ja.

If your application assumes a different message structure, as in this case, you will need to do the validation yourself.