2.3.0 • Published 4 years ago

think_i18n v2.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

介绍


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');
2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.2.0

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago