Skip to content

项目国际化方案,开发阶段不用关注国际化,在build、start阶段 通过AST来实现多语api转换

Notifications You must be signed in to change notification settings

tinper-acs/lang-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lang-demo

本示例结合 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

1. 配置.babelrc,实现中文提取

查看详细配置和原理,请参考

babel-plugin-transform-lang-cli

https://www.npmjs.com/package/babel-plugin-transform-lang-cli

"plugins": [
    "babel-plugin-transform-lang-cli"
]

2.配置运行时加载

ac-lang-cn

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

About

项目国际化方案,开发阶段不用关注国际化,在build、start阶段 通过AST来实现多语api转换

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published