vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Add option to support working with flattened json using dot ('.') as separator

Open RobinB-Gbanga opened this issue 4 years ago • 3 comments
trafficstars

Currently, if I look up this key: $t('mainMenu.buttonStart')

The key is only found if I use a nested json:

{
  "mainMenu": {
    "buttonStart": "Start!"
  }
}

But not if I use a flat json representation:

{
  "mainMenu.buttonStart": "Start!"
}

For a current project, we are interfacing with a translation source that can only output flat json files. At the same time, however, we'd like to have the benefits of a namespaced/scoped key naming convention. For example, the tool we use in VSCode offers a nice tree view when using dots as namespace/scope separators.

It would be great if vue-i18n would offer a setting to support flattened json files (or, in other words, to treat the dot ('.') as a normal/literal character).

Thanks!

RobinB-Gbanga avatar Dec 30 '20 09:12 RobinB-Gbanga

Thank you for your feedback.

In order for vue-i18n-next to support this, it needs to support the custom message resolver I/F.

Since the message resolver is modularized, we need to extend the custom message resolver so that it can be optioned by vue-i18n. https://github.com/intlify/vue-i18n-next/tree/master/packages/message-resolver

kazupon avatar Dec 31 '20 18:12 kazupon

Fixed with #294

kazupon avatar Jan 16 '21 15:01 kazupon

Re-open, so #294 is breaking change. https://github.com/intlify/vue-i18n-next/issues/271

kazupon avatar Jan 21 '21 03:01 kazupon