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).
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
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
- 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 Discussions