egg icon indicating copy to clipboard operation
egg copied to clipboard

评估 i18n 依赖库

Open popomore opened this issue 7 years ago • 6 comments

https://github.com/mashpie/i18n-node

这个库的 star 数还挺高,API 也类似,看看切换成本高不高

popomore avatar Jan 12 '17 17:01 popomore

@popomore , 现有方案egg-i18n (基于koa-locales)的痛点是什么?i18n-node或其它的类库是打算用来替换koa-locales的吗?

zhang-z avatar Oct 25 '17 14:10 zhang-z

我还没有很深入的使用,如果能和社区现有模块接轨就可以共建了,开发成本会小很多。

popomore avatar Oct 25 '17 14:10 popomore

现在的 i18n 只是能用,并不好用。试想一下,你有 80 个页面要做多语言,都写在 en-US.jsonzh-CN.json 怎么维护?

实际业务中都是按页面来拆分的,然后再合并成插件需要的文件

tudou527 avatar Jan 19 '18 06:01 tudou527

我觉得可以考虑下 vscode 的方式。在代码中先默认写英文的~

比如在 app/controller/logger.js 这么写

const { localize } = require('xxxx');
localize('openLogsFolder', "Open Logs Folder");

然后会自动生成其他语言的文件

config/locales/en/controller/logger.i18n.json
config/locales/zh/controller/logger.i18n.json

里面的 key 都是自动对齐的,哪些有翻译,哪些没翻译一目了然。文件自动切分,用户在随时进行翻译~ 写代码也可以更专注。

完美~

okoala avatar Jan 19 '18 13:01 okoala

@0maxxam0 has funded $10.00 to this issue. See it on IssueHunt

IssueHuntBot avatar Nov 29 '18 13:11 IssueHuntBot

@dead-horse 有实践,看看是不是抽象出来。

popomore avatar Apr 24 '19 06:04 popomore