【发布时间】:2016-09-13 14:49:18
【问题描述】:
目前在使用babel-plugin-react-intl 时,会使用“id”、“description”和“defaultMessage”为每个组件创建单独的 json。我需要的是只创建一个包含单个对象的 json,其中所有“id”作为“键”,“defaultMessage”作为“值”
现状:
ComponentA.json
[
{
"id": "addEmoticonA",
"description": "Add emoticon",
"defaultMessage": "Insert Emoticon"
},
{
"id": "addPhotoA",
"description": "Add photo",
"defaultMessage": "Insert photo"
}
]
ComponentB.json
[
{
"id": "addEmoticonB",
"description": "Add emoji",
"defaultMessage": "Insert Emoji"
},
{
"id": "addPhotoB",
"description": "Add picture",
"defaultMessage": "Insert picture"
}
]
我需要翻译什么。
final.json
{
"addEmoticonA": "Insert Emoticon",
"addPhotoA": "Insert photo",
"addEmoticonB": "Insert Emoji",
"addPhotoB": "Insert picture"
}
有什么方法可以完成这个任务吗?可能是通过使用python脚本或任何东西。即从不同的 json 文件制作单个 json 文件。或者直接使用 babel-plugin-react-intl 制作单个 json 文件
【问题讨论】:
标签: react-intl