angular i18n:支持JSON嵌套翻译文件

brtdzjyr  于 4个月前  发布在  Angular
关注(0)|答案(2)|浏览(41)

Which @angular/* package(s) are relevant/related to the feature request?

  • No response*

Description

Right now, i18n supports JSON source files (fantastic, loving it).
One thing that is giving us a lot of extra work is that nested JSON does not seem to be supported.
Example: right now we have to flatten the structure, let's say we have a feature:

{
    "locale": "en",
    "translations": {
        "feature.title": "Lorem ipsum title",
        "feature.content": "Lorem ipsum content",
        "feature.para1": "Lorem ipsum 1",
        "feature.para2": "Lorem ipsum 2",
        "feature.para3": "Lorem ipsum 3",
        "feature.para4": "Lorem ipsum 4",
        "feature.para5": "Lorem ipsum 5",
        "feature.para6": "Lorem ipsum 6"       
    }
}

Ideally this should be possible instead:

{
  "locale": "en",
  "translations": {
      "feature": {
        "title": "Lorem ipsum title",
        "content": "Lorem ipsum content",
        "para1": "Lorem ipsum 1",
        "para2": "Lorem ipsum 2",
        "para3": "Lorem ipsum 3",
        "para4": "Lorem ipsum 4",
        "para5": "Lorem ipsum 5",
        "para6": "Lorem ipsum 6"
      }  
  }
}

The latter version makes it much more readable, and requires less repeated boilerplate.
Thanks

Proposed solution

Support nested JSON language files

Alternatives considered

Write scripts that convert nested source files, to flat versions.

34gzjxbg

34gzjxbg1#

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.

hgqdbh6s

hgqdbh6s2#

感谢您提交您的功能请求!看起来在投票过程中,它没有收集到足够的票数进入下一阶段。
我们希望保持Angular丰富且符合人体工程学,同时关注其范围和学习过程。如果您认为您的请求可能超出了Angular的范围,我们鼓励您与community合作,将其发布为开源项目package
您可以在我们的文档中找到有关功能请求过程的更多详细信息。

相关问题