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

mergeLocaleMessage in petite 18n broken after 9.6.0 - converts to nested object by itself

chojnicki opened this issue · comments

Reporting a bug?

After upgrading petite-vue-i18n from 9.5.0 translations on app broke (messages not found).

I'm using simple key, not nested objects (by default in petite).

Screenshot from 2024-01-29 19-40-26

Translations are lazy loaded from .json files and merged.

const messages = await import(`./locales/${category}/${locale}.json`)
i18n.global.mergeLocaleMessage(locale, messages.default)

I debugged it via i18n.global.getLocaleMessage('pl') and noticed that my translations are nested, WTF :D

Screenshot from 2024-01-29 19-36-28

By downgrading version after version I discovered that issue is with 9.6.0, and noticed noticed this commit in changelog:
edaf498

Using flatConfig in i18n config does not help, and I guess should not be used in petite anyway.

I've commented this line in petite-vue-i18n dist source:

handleFlatJson(_message[key]);

and it works.

Then I noticed that in setLocaleMessage there is condition

if (flatJson) {

for that handleFlatJson, but it's missing in mergeLocaleMessage. Why? After adding this, again everything works. Was this on purpose? I case this is a typo, I will provide pull request. If not - @kazupon please provide other solution :(

Expected behavior

Keys like 'a.b.c' should be treated like strings, not transformed into object.

Reproduction

Described above.

System Info

Described above.

Screenshot

No response

Additional context

No response

Validations