New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

egg-i18n

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-i18n - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

25

app.js
'use strict';
const locales = require('koa-locales');
const fs = require('fs');
const path = require('path');

@@ -14,6 +15,6 @@ const debug = require('debug')('egg:plugin:i18n');

*
* 统一存放在 `config/locales/*.js` 下,如包含英文,简体中文,繁体中文的语言文件:
* 统一存放在 `config/locale/*.js` 下( 兼容`config/locales/*.js` ),如包含英文,简体中文,繁体中文的语言文件:
*
* ```
* - config/locales/
* - config/locale/
* - en-US.js

@@ -30,3 +31,3 @@ * - zh-CN.js

* ```js
* // config/locales/zh-CN.js
* // config/locale/zh-CN.js
* module.exports = {

@@ -40,3 +41,3 @@ * "Email": "邮箱",

* ```js
* // config/locales/en-US.js
* // config/locale/en-US.js
* module.exports = {

@@ -49,3 +50,3 @@ * "Email": "Email",

* ```js
* // config/locales/zh-CN.json
* // config/locale/zh-CN.json
* {

@@ -113,5 +114,15 @@ * "email": "邮箱",

app.config.i18n.dirs = Array.isArray(app.config.i18n.dirs) ? app.config.i18n.dirs : [];
// 按 egg > 插件 > 框架 > 应用的顺序遍历 config/locales 目录,加载所有配置文件
// 按 egg > 插件 > 框架 > 应用的顺序遍历 config/locale(config/locales) 目录,加载所有配置文件
for (const unit of app.loader.getLoadUnits()) {
app.config.i18n.dirs.push(path.join(unit.path, 'config/locales'));
const localePath = path.join(unit.path, 'config/locale');
/**
* 优先选择 `config/locale` 目录下的多语言文件
* 避免 2 个目录同时存在时可能导致的冲突
*/
if (fs.existsSync(localePath)) {
app.config.i18n.dirs.push(localePath);
} else {
app.config.i18n.dirs.push(path.join(unit.path, 'config/locales'));
}
}

@@ -118,0 +129,0 @@

1.2.0 / 2017-09-13
==================
**features**
* [[`1117129`](http://github.com/eggjs/egg-i18n/commit/1117129ce0153d317d376a2692b3de14b94a6717)] - feat: use config/locale/*.js as default I18N folder (#7) (tudou527 <<tudou527@users.noreply.github.com>>)
1.1.1 / 2017-04-19

@@ -3,0 +9,0 @@ ==================

{
"name": "egg-i18n",
"version": "1.1.1",
"version": "1.2.0",
"eggPlugin": {

@@ -56,2 +56,2 @@ "name": "i18n"

}
}
}

@@ -27,3 +27,3 @@ # egg-i18n

- 支持多种语言独立配置,统一存放在 config/locales/*.js 下;
- 支持多种语言独立配置,统一存放在 config/locale/*.js 下( 兼容`config/locales/*.js` );
- 提供 Middleware 为 View 提供 `__`, `gettext` 函数获取多语言文案;

@@ -65,3 +65,3 @@ - 基于 URL 参数 `locale` 修改语言显示,同时会记录到 Cookie,下次请求会用 Cookie 里面的语言方案。

```js
// config/locales/zh-CN.js
// config/locale/zh-CN.js
module.exports = {

@@ -75,3 +75,3 @@ "Email": "邮箱",

```js
// config/locales/en-US.js
// config/locale/en-US.js
module.exports = {

@@ -85,3 +85,3 @@ "Email": "Email",

```json
// config/locales/zh-CN.json
// config/locale/zh-CN.json
{

@@ -96,3 +96,3 @@ "email": "邮箱",

I18n 为你提供 `__` (Alias: `gettext`) 函数,让你可以轻松获得 locales 文件夹下面的多语言文本。
I18n 为你提供 `__` (Alias: `gettext`) 函数,让你可以轻松获得 locale 文件夹下面的多语言文本。

@@ -99,0 +99,0 @@ > NOTE: __ 是两个下划线哦!

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc