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

It is recommended to optimize the multilingual JSON format(建议优化多语种的JSON格式)

Open koibi2 opened this issue 2 years ago • 3 comments

Clear and concise description of the problem

The translated text JSON format of Vue-i18n is like this: It's cumbersome to maintain 2 JSON structures to keep them uniform. (Vue-i18n 的翻译文本 JSON 格式是这样的: 维护2个JSON结构保持统一很麻烦。)

{
  en: {
    message: {
      hello: 'hello world'
    }
  },
  ja: {
    message: {
      hello: 'こんにちは、世界'
    }
  },
  zh-CN: {
    message: {
      hello: '你好,世界'
    }
  },

Suggested solution

It is recommended to separate languages ​​with an array. This is easy to maintain. (建议用数组分隔语种。这样易于维护。)

const $t = {
      home: {
          search: ['搜索', 'search', '検索'], // Chinese、English、Japanese
          name: ['姓名', 'name', '名前'],
      }
}

Alternative

No response

Additional context

No response

Validations

koibi2 avatar Apr 24 '22 09:04 koibi2

我也觉得目前的JSON语言维护很麻烦,尤其是大项目所有内容国际化数据量很大的时候,就更麻了,不光数据维护很难,就连数据取值都变得复杂了,KEY很难去记忆,在代码里可读性很低

Dongjian413 avatar Jun 07 '22 08:06 Dongjian413

I also feel that the current JSON language maintenance is very troublesome, especially when all the contents of large projects are internationalized and the data volume is large, it is even more difficult. Not only the data maintenance is difficult, but also the data value becomes complicated, the KEY is difficult to remember, and the readability in the code is very low

Dongjian413 avatar Jun 07 '22 08:06 Dongjian413

I think the suggested format makes it hard to add/remove language. The original format user can separate different languages into different files, like en.json, and cn.json.

dews avatar Aug 31 '23 08:08 dews