Skip to content

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

@NamesMT

Description

@NamesMT

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions