How to configure `I18n Ally` VsCode plugin to read my locals from one single file?

7.4k Views Asked by At

I'm using vue-i18n package to translate my Vue project and want to use "I18n Ally" vs code extention to manage translations. The default folder structure for this extension is this:

  locales         # i18n, langs, locale are also acceptable
  ├── en.json
  ├── de-DE.json
  ├── zh-CN.yml   # YAML
  ├── zh-TW.ts    # You can mix different formats
  ├── ...
  └── <country-code>.json

But I have one single translation file with this format:

{
 "en": {
    "users": {
      "title": "Users list",
      "menu": {
        "show_users": "Display users",
        "hands_down": "Hands down",
        "unblock_all": "Unblock all"
      },
...

And I cannot configure the extension to read this configuration.

1

There are 1 best solutions below

0
On

Author of i18n Ally here. Currently, we don't support the locale code as top-level keys in json files. I'd suggest using the following format in dedicated files for each locale, which will also get better support over other i18n tools.

{
   "users": {
      "title": "Users list",
      "menu": {
        "show_users": "Display users",
        "hands_down": "Hands down",
        "unblock_all": "Unblock all"
      },
...

This should be a better practice as your application grows as well. Thanks for the understanding and hope you enjoy the extension.