Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

petite-vue-i18n: flatJson bug (update: actually confusion, not bug) #2011

Open
4 tasks done
NamesMT opened this issue Nov 12, 2024 · 0 comments
Open
4 tasks done

petite-vue-i18n: flatJson bug (update: actually confusion, not bug) #2011

NamesMT opened this issue Nov 12, 2024 · 0 comments
Labels
Status: Review Needed Request for review comments

Comments

@NamesMT
Copy link

NamesMT commented Nov 12, 2024

Reporting a bug?

petite-vue-i18n cannot work with flatJson enabled, but when disabled, it works fine.
See #2010

TL;DR: petite-vue-i18n by default only works with a key:value (flat) json messages format, flatJson will recursively transforms a flat json key into a nested key, which will broke petite-vue-i18n when resolving messages, this is a problem of flatJson description rather than petite-vue-i18n's bug.

Expected behavior

.

Reproduction

import { createI18n } from 'petite-vue-i18n'

// Initialize i18n  
const i18n = createI18n({
  legacy: false,
  flatJson: true,
  locale: 'en',
  fallbackLocale: 'en',
  fallbackWarn: false,
  missingWarn: false,
  messages: {
    en: { 'word.hello': 'Hello' },
  },
})

const test = i18n.global.t('word.hello')

console.log({ test })

Swapping to vue-i18n works fine.

System Info

.

Screenshot

No response

Additional context

No response

Validations

@NamesMT NamesMT added the Status: Review Needed Request for review comments label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

1 participant