{"_id":"egg-i18n","_rev":"1213162","name":"egg-i18n","description":"i18n plugin for egg","dist-tags":{"latest":"2.1.1"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"modified":"2021-10-13T05:46:41.000Z","created":"2016-05-26T09:07:22.697Z","2.1.1":"2019-04-30T12:14:31.497Z","2.1.0":"2019-04-28T12:07:33.034Z","2.0.0":"2017-11-10T08:13:48.379Z","1.2.0":"2017-09-13T11:08:45.855Z","1.1.1":"2017-04-19T13:22:48.456Z","1.1.0":"2017-01-13T07:30:33.843Z","1.0.2":"2016-08-26T15:39:22.206Z","1.0.1":"2016-08-16T15:05:08.866Z","1.0.0":"2016-08-02T14:09:34.330Z","0.0.1":"2016-05-26T09:07:22.697Z"},"users":{},"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"versions":{"2.1.1":{"name":"egg-i18n","version":"2.1.1","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 8.0.0"},"ci":{"version":"8, 10, 12"},"dependencies":{"debug":"^3.1.0","koa-locales":"^1.11.0"},"devDependencies":{"autod":"^2.10.1","egg":"^2.21.1","egg-bin":"^4.3.5","egg-ci":"^1.8.0","egg-mock":"^3.13.1","egg-view-nunjucks":"^2.1.4","eslint":"^4.10.0","eslint-config-egg":"^5.1.1","pedding":"^1.1.0"},"gitHead":"f5785a96e9359bc5f456f2c893aa2f9ed697d873","_id":"egg-i18n@2.1.1","_npmVersion":"5.8.0","_nodeVersion":"10.15.1","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"3e1a638edbb6a4437229b163b8b3715d24376f0d","size":5796,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-2.1.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-i18n_2.1.1_1556626471310_0.6478848945855655"},"_hasShrinkwrap":false,"publish_time":1556626471497,"_cnpm_publish_time":1556626471497},"2.1.0":{"name":"egg-i18n","version":"2.1.0","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 8.0.0"},"ci":{"version":"8, 10, 11"},"dependencies":{"debug":"^3.1.0","koa-locales":"^1.9.0"},"devDependencies":{"autod":"^2.10.1","egg":"^2.21.1","egg-bin":"^4.3.5","egg-ci":"^1.8.0","egg-mock":"^3.13.1","egg-view-nunjucks":"^2.1.4","eslint":"^4.10.0","eslint-config-egg":"^5.1.1","pedding":"^1.1.0"},"gitHead":"fa6c2bfa662fc898189bc045967f564d86cf8f69","_id":"egg-i18n@2.1.0","_npmVersion":"6.5.0","_nodeVersion":"12.0.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"e098bb8e80662a2bab52229e89a7b7af6e8854ba","size":5651,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-2.1.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-i18n_2.1.0_1556453252902_0.8365667012376425"},"_hasShrinkwrap":false,"publish_time":1556453253034,"_cnpm_publish_time":1556453253034},"2.0.0":{"name":"egg-i18n","version":"2.0.0","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 8.0.0"},"files":["app","config","app.js"],"ci":{"version":"8, 9"},"dependencies":{"debug":"^3.1.0","koa-locales":"^1.7.0"},"devDependencies":{"autod":"^2.10.1","egg":"next","egg-bin":"^4.3.5","egg-ci":"^1.8.0","egg-mock":"^3.13.1","egg-view-nunjucks":"^2.1.4","eslint":"^4.10.0","eslint-config-egg":"^5.1.1","pedding":"^1.1.0"},"gitHead":"d0a5af4d61cad4eb2ca79dda97fa10b1deb8ea8d","_id":"egg-i18n@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.4.0","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"2180ea3ebbd7e3bf610e5cc8582e9106b0f69111","size":5451,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-2.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-i18n-2.0.0.tgz_1510301628303_0.08064584340900183"},"directories":{},"publish_time":1510301628379,"_hasShrinkwrap":false,"_cnpm_publish_time":1510301628379},"1.2.0":{"name":"egg-i18n","version":"1.2.0","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 6.0.0"},"files":["app","config","app.js"],"ci":{"version":"6, 7"},"dependencies":{"debug":"^2.6.0","koa-locales":"^1.5.2"},"devDependencies":{"autod":"^2.7.1","egg":"^0.7.0","egg-bin":"^1.10.0","egg-ci":"^1.1.0","egg-mock":"^2.0.0","eslint":"^3.13.1","eslint-config-egg":"^3.2.0","pedding":"^1.1.0","supertest":"^2.0.1"},"gitHead":"3ef32ac33232faa26e4a79212e1566737c3d67f8","_id":"egg-i18n@1.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"f376b2b366f51adc21146a4a4778ccd53cfdb5c8","size":5303,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.2.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/egg-i18n-1.2.0.tgz_1505300925738_0.9650539013091475"},"directories":{},"publish_time":1505300925855,"_hasShrinkwrap":false,"_cnpm_publish_time":1505300925855},"1.1.1":{"name":"egg-i18n","version":"1.1.1","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 6.0.0"},"files":["app","config","app.js"],"ci":{"version":"6, 7"},"dependencies":{"debug":"^2.6.0","koa-locales":"^1.5.2"},"devDependencies":{"autod":"^2.7.1","egg":"^0.7.0","egg-bin":"^1.10.0","egg-ci":"^1.1.0","egg-mock":"^2.0.0","eslint":"^3.13.1","eslint-config-egg":"^3.2.0","pedding":"^1.1.0","supertest":"^2.0.1"},"gitHead":"269f6c8dd9028c48c015ee5f750e2a739dd6f23e","_id":"egg-i18n@1.1.1","_shasum":"04756ebee09eaf4b65d01772980e35d4a5965504","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.6.0","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"04756ebee09eaf4b65d01772980e35d4a5965504","size":5006,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.1.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-i18n-1.1.1.tgz_1492608168206_0.8605538993142545"},"directories":{},"publish_time":1492608168456,"_cnpm_publish_time":1492608168456,"_hasShrinkwrap":false},"1.1.0":{"name":"egg-i18n","version":"1.1.0","eggPlugin":{"name":"i18n"},"description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov","autod":"autod"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 6.0.0"},"files":["app","config","app.js"],"ci":{"version":"6, 7"},"dependencies":{"debug":"^2.6.0","koa-locales":"^1.5.2"},"devDependencies":{"autod":"^2.7.1","egg":"^0.7.0","egg-bin":"^1.10.0","egg-ci":"^1.1.0","egg-mock":"^2.0.0","eslint":"^3.13.1","eslint-config-egg":"^3.2.0","pedding":"^1.1.0","supertest":"^2.0.1"},"gitHead":"4b8e363c5718d212acbfedf9c9a59d4d947753a8","_id":"egg-i18n@1.1.0","_shasum":"579a176288cf20deb5232a589c40416e5bb3bfb1","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"579a176288cf20deb5232a589c40416e5bb3bfb1","size":4985,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.1.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-i18n-1.1.0.tgz_1484292633602_0.14273986383341253"},"directories":{},"publish_time":1484292633843,"_cnpm_publish_time":1484292633843,"_hasShrinkwrap":false},"1.0.2":{"name":"egg-i18n","version":"1.0.2","description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 4.0.0"},"files":["app","config","app.js"],"ci":{"version":"4, 6"},"devDependencies":{"egg":"test","egg-bin":"1","egg-mock":"*","eslint":"3","eslint-config-egg":"3","pedding":"1","should":"10","supertest":"1"},"dependencies":{"debug":"^2.2.0","koa-locales":"^1.5.1"},"eggPlugin":{"name":"i18n"},"gitHead":"38ae2fc995818f1d4558517f28f48fd5c818b6fc","_id":"egg-i18n@1.0.2","_shasum":"d9b244eb9db3e435a4f108c50a80007ceca37e30","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.5.0","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"d9b244eb9db3e435a4f108c50a80007ceca37e30","size":4791,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.0.2.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-i18n-1.0.2.tgz_1472225960390_0.7182742457371205"},"directories":{},"publish_time":1472225962206,"_cnpm_publish_time":1472225962206,"_hasShrinkwrap":false},"1.0.1":{"name":"egg-i18n","version":"1.0.1","description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 4.0.0"},"files":["app","config","app.js"],"ci":{"version":"4, 6"},"devDependencies":{"egg":"test","egg-bin":"1","egg-mock":"*","eslint":"3","eslint-config-egg":"3","pedding":"1","should":"10","supertest":"1"},"dependencies":{"debug":"^2.2.0","koa-locales":"^1.5.1"},"eggPlugin":{"name":"i18n"},"gitHead":"041cad42035e6f5f5c3f5a8254cb6b27735f080b","_id":"egg-i18n@1.0.1","_shasum":"79a1d7ed0a0c13dff8164ebe5f97525177d84407","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"79a1d7ed0a0c13dff8164ebe5f97525177d84407","size":4741,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.0.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-i18n-1.0.1.tgz_1471359906376_0.49251580191776156"},"directories":{},"publish_time":1471359908866,"_cnpm_publish_time":1471359908866,"_hasShrinkwrap":false},"1.0.0":{"name":"egg-i18n","version":"1.0.0","description":"i18n plugin for egg","main":"index.js","scripts":{"lint":"eslint lib test *.js","test":"npm run lint && egg-bin test","cov":"egg-bin cov","ci":"npm run lint && npm run cov"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg-i18n.git"},"keywords":["egg","i18n"],"author":{"name":"gxcsoccer","email":"gxcsoccer@126.com"},"license":"MIT","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"homepage":"https://github.com/eggjs/egg-i18n#readme","engines":{"node":">= 4.0.0"},"files":["app","config","app.js"],"ci":{"version":"4, 6"},"devDependencies":{"egg":"*","egg-bin":"1","egg-mock":"*","eslint":"3","eslint-config-egg":"3","mm":"1","pedding":"1","should":"10","supertest":"1"},"dependencies":{"debug":"^2.2.0","koa-locales":"^1.5.1"},"eggPlugin":{"name":"i18n"},"gitHead":"7b69951d4ecdbc9c408028610d7ef51ff109f431","_id":"egg-i18n@1.0.0","_shasum":"2b392ab261e359f8613eb943b4f2d0ac070ff79c","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.1","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"dist":{"shasum":"2b392ab261e359f8613eb943b4f2d0ac070ff79c","size":4688,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-1.0.0.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/egg-i18n-1.0.0.tgz_1470146973307_0.24972278741188347"},"directories":{},"publish_time":1470146974330,"_cnpm_publish_time":1470146974330,"_hasShrinkwrap":false},"0.0.1":{"name":"egg-i18n","version":"0.0.1","description":"egg plugin <egg-i18n>","keywords":["egg","eggjs","egg-plugin"],"homepage":"https://github.com/eggjs/egg-i18n","license":"MIT","author":{"name":"eggjs"},"contributors":[{"name":"TZ","email":"atian25@qq.com"},{"name":"popomore","email":"sakura9515@gmail.com"},{"name":"fengmk2","email":"m@fengmk2.com"},{"name":"dead-horse","email":"heyiyu.deadhorse@gmail.com"}],"repository":{"type":"git","url":"git+ssh://git@github.com/eggjs/egg-i18n.git"},"bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"_id":"egg-i18n@0.0.1","scripts":{},"_shasum":"2f8a7f64f84f50677dbb94396dfb457fdc27ffcf","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.4","_npmUser":{"name":"atian25","email":"atian25@qq.com"},"dist":{"shasum":"2f8a7f64f84f50677dbb94396dfb457fdc27ffcf","size":422,"noattachment":false,"key":"/egg-i18n/-/egg-i18n-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/egg-i18n/download/egg-i18n-0.0.1.tgz"},"maintainers":[{"name":"atian25","email":"atian25@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/egg-i18n-0.0.1.tgz_1464253642183_0.4735534554347396"},"directories":{},"publish_time":1464253642697,"_cnpm_publish_time":1464253642697,"_hasShrinkwrap":false}},"readme":"# egg-i18n\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-i18n.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-i18n\n[travis-image]: https://img.shields.io/travis/eggjs/egg-i18n.svg?style=flat-square\n[travis-url]: https://travis-ci.org/eggjs/egg-i18n\n[codecov-image]: https://codecov.io/github/eggjs/egg-i18n/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/eggjs/egg-i18n?branch=master\n[david-image]: https://img.shields.io/david/eggjs/egg-i18n.svg?style=flat-square\n[david-url]: https://david-dm.org/eggjs/egg-i18n\n[snyk-image]: https://snyk.io/test/npm/egg-i18n/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/egg-i18n\n[download-image]: https://img.shields.io/npm/dm/egg-i18n.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-i18n\n\n可以为你的应用提供多语言的特性\n\n## 功能\n\n- 支持多种语言独立配置，统一存放在 config/locale/\\*.js 下（ 兼容 `config/locales/*.js` ）；\n- 提供 Middleware 为 View 提供 `\\_\\_`, `gettext` 函数获取多语言文案；\n- 基于 URL 参数 `locale` 修改语言显示，同时会记录到 Cookie，下次请求会用 Cookie 里面的语言方案。\n\n## 配置\n\n默认处于关闭状态，你需要在 `config/plugin.js` 开启它：\n\n```js\n// config/plugin.js\nexports.i18n = {\n  enable: true,\n  package: 'egg-i18n',\n};\n```\n\n你可以修改 `config/config.default.js` 来设定 i18n 的配置项：\n\n```js\n// config/config.default.js\nexports.i18n = {\n  // 默认语言，默认 \"en_US\"\n  defaultLocale: 'zh-CN',\n  // URL 参数，默认 \"locale\"\n  queryField: 'locale',\n  // Cookie 记录的 key, 默认：\"locale\"\n  cookieField: 'locale',\n  // Cookie 的 domain 配置，默认为空，代表当前域名有效\n  cookieDomain: '',\n  // Cookie 默认 `1y` 一年后过期， 如果设置为 Number，则单位为 ms\n  cookieMaxAge: '1y',\n};\n```\n\n其实大部分时候，你只需要修改一下 `defaultLocale` 设定默认的语言。\n\n## 编写你的 I18n 多语言文件\n\n```js\n// config/locale/zh-CN.js\nmodule.exports = {\n  \"Email\": \"邮箱\",\n  \"Welcome back, %s!\": \"欢迎回来，%s!\",\n  \"Hello %s, how are you today?\": \"你好 %s, 今天过得咋样？\",\n};\n```\n\n```js\n// config/locale/en-US.js\nmodule.exports = {\n  \"Email\": \"Email\",\n};\n```\n\n或者也可以用 JSON 格式的文件：\n\n```json\n// config/locale/zh-CN.json\n{\n  \"email\": \"邮箱\",\n  \"login\": \"帐号\",\n  \"createdAt\": \"注册时间\"\n}\n```\n\n## 使用 I18n 函数获取语言文本\n\nI18n 为你提供 `__` (Alias: `gettext`) 函数，让你可以轻松获得 locale 文件夹下面的多语言文本。\n\n> NOTE: __ 是两个下划线哦！\n\n- ctx.__ = function (key, value[, value2, ...]): 类似 util.format 接口\n- ctx.__ = function (key, values): 支持数组下标占位符方式，如\n\n```js\nctx.__('{0} {0} {1} {1}'), ['foo', 'bar'])\nctx.gettext('{0} {0} {1} {1}'), ['foo', 'bar'])\n=>\nfoo foo bar bar\n```\n\n### Controllers 下的使用示例\n\n```js\nmodule.exports = function* () {\n  this.body = {\n    message: this.__('Welcome back, %s!', this.user.name)\n    // 或者使用 gettext，如果觉得 __ 不好看的话\n    // message: this.gettext('Welcome back, %s!', this.user.name)\n    user: this.user,\n  };\n};\n```\n\n### View 文件下的使用示例\n\n```html\n<li>{{ __('Email') }}: {{ user.email }}</li>\n<li>\n  {{ __('Hello %s, how are you today?', user.name) }}\n</li>\n<li>\n  {{ __('{0} {0} {1} {1}'), ['foo', 'bar']) }}\n</li>\n```\n\n### 修改应用的默认语言\n\n你可以用下面几种方式修改应用的当前语言（修改或会记录到 Cookie)，下次请求直接用设定好的语言。\n\n优先级从上到下：\n\n- query: /?locale=en-US\n- cookie: locale=zh-TW\n- header: Accept-Language: zh-CN,zh;q=0.5\n","_attachments":{},"homepage":"https://github.com/eggjs/egg-i18n#readme","bugs":{"url":"https://github.com/eggjs/egg-i18n/issues"},"license":"MIT"}