本示例结合 babel-plugin-transform-lang-cli(bable plugin 中文提取工具)、ac-lang-cn(运行时解析多语),提供一个完整的示例。
npm install --save ac-lang-cn
npm install --save-dev babel-plugin-transform-lang-cli
查看详细配置和原理,请参考
babel-plugin-transform-lang-cli
https://www.npmjs.com/package/babel-plugin-transform-lang-cli
"plugins": [
"babel-plugin-transform-lang-cli"
]
window.lang = require("ac-lang-cn").default;
lang.init({"zhcn":require('./pack/zh_cn.json')}, null); //加载多语文件
//...do somthing ,app entry
访问 http://ip:3005/xx?locale=zh_CN/en_US
http://127.0.0.1:3005/?locale=zh_CN
npm run start