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

Dynamic language loading with flatJson does not work for deeply linked messages

joukokar opened this issue · comments

Reporting a bug?

When using lazy language loading with flatJson: true, and setting messages with

i18n.global.setLocaleMessage('locale', { "simple": "simple", "nested.key": "nested", "content": "@:simple @:nested.key" })

only the top level linked messages are working correctly.

$t("content")

results in

simple

Expected behavior

Nested objects also can be referred in linked message.

$t("content")

should become

simple nested

Reproduction

Following the lazy loading guide, but having flatJson: true the "@:nested.key" links stop working while "@:simple" works.

https://stackblitz.com/edit/vitejs-vite-wymdb6?file=src%2Fmain.ts

System Info

Binaries:
    Node: 18.17.1 - ~/.nodenv/versions/18.17.1/bin/node
    npm: 9.6.7 - ~/.nodenv/versions/18.17.1/bin/npm
    pnpm: 8.9.2 - ~/.nodenv/versions/18.17.1/bin/pnpm
  npmPackages:
    @intlify/core-base: workspace:* => 9.5.0 
    @intlify/message-compiler: workspace:* => 9.5.0 
    vitepress: 1.0.0-rc.22 => 1.0.0-rc.20 
    vitest: ^0.34.3 => 0.34.3 
    vue: 3.3.4 => 3.3.4 
    vue-i18n: workspace:* => 9.5.0

Screenshot

No response

Additional context

Possibly bit related PR: #1549

As a workaround, I am converting flat JSON manually into nested one before calling setLocaleMessage but it would be best to reuse the exactly same conversion logic as in vue-i18n.

Validations