think_i18n

2.3.0 • Public • Published

介绍


npm version

Internationalization and localization for ThinkKoa.

安装


npm i think_i18n

使用


注意: i18n中间件需要ThinkKoa 框架版本 >= 1.4.0

1、项目中增加中间件 middleware/i18n.js

module.exports = require('think_i18n');

2、项目中间件配置 config/middleware.js:

list: [...,'i18n'], //加载的中间件列表
config: { //中间件配置
    ...,
    i18n: {
        language: 'zh-cn', //默认语言设置 zh-cn en
        lang_pathname: true, //开启多语言解析 /zh-cn/home/index  自动解析为 /home/index使用中文语言
        language_path: process.env.APP_PATH + '/config/lang', //多语言配置文件目录
    }
}

3、使用

// in controller
let location = this.app.i18n('test');
 
// in middleware 
let location = app.i18n('test');

Readme

Keywords

none

Package Sidebar

Install

npm i think_i18n

Weekly Downloads

0

Version

2.3.0

License

MIT

Unpacked Size

9.52 kB

Total Files

5

Last publish

Collaborators

  • richenlin