Skip to content

Commit

Permalink
[add] 处理本地化 keys
Browse files Browse the repository at this point in the history
  • Loading branch information
icepy committed Apr 13, 2019
1 parent 7211572 commit a32f72a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,32 @@ i18n 国际化运营支持平台
- [farm-translation](./packages/farm-translation) 命令行工具
- [webpack-extract-i18n-plugin](./packages/webpack-extract-i18n-plugin) Webpack 插件
- [farm-i18n](./extension/farm-i18n) 管理 i18n 国际化配置文件的 Extension

## 如何使用

请先下载 Chrome Extension 使用 `farm-i18n` 来管理你的 i18n 配置文件。

![](./extension/farm-i18n/farm-i18n.gif)

格式如下:

```json
{
"appName": {
"zh_CN": {"message": "farm-i18n"}
},
"OPTIONS_MENU_I18N_LIST": {
"zh_CN": {"message": "翻译任务"}
},
"OPTIONS_CREATE_I18N_TASK": {
"zh_CN": {"message": "创建翻译任务"}
},
"OPTIONS_CREATE_TEXT": {
"zh_CN": {"message": "创建"}
}
}
```

你可以使用扩展来输出不同语言的翻译格式,开发者可以将这份文件保存到本地。

前端开发者可以使用 [webpack-extract-i18n-plugin](./packages/webpack-extract-i18n-plugin) 来做提取自动生存 i18n 真正需要依赖的文件和目录。
2 changes: 2 additions & 0 deletions extension/farm-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

farm-i18n 是一个管理 i18n 国际化配置文件的扩展

![](./farm-i18n.gif)

## develop

```bash
Expand Down
Binary file added extension/farm-i18n/farm-i18n.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion extension/farm-i18n/src/options/pages/translate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ class Translate extends React.Component<IProps, IState> {
}
i = i + 1;
}
data.localizesResult = JSON.stringify(localizesResult);
const { localizes } = data;
if (!(localizes.indexOf(localize) > -1)) {
data.localizes.push(localize);
}
data.localizesResult = JSON.stringify(localizesResult, null, 2);
singletonData.setData(data.id, data);
singletonData.saveStorage();
this.setState({
Expand Down

0 comments on commit a32f72a

Please sign in to comment.