Skip to content

Commit 393ba44

Browse files
committed
优化i8n方案
1 parent 6e431d3 commit 393ba44

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

i18n/index.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

i18n/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["en_US", "zh_CN"]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"main": "server.js",
1111
"scripts": {
1212
"dev": "PLUGIN=$(pwd) NODE_ENV=development babel-node node_modules/codingSDK/server.js",
13-
"i18n": "I18nTargetRoot=$(pwd)/i18n/en_US babel-node node_modules/codingSDK/.script/generateI18n $(pwd)/src"
13+
"i18n": "I18nTargetRoot=$(pwd)/i18n babel-node node_modules/codingSDK/.script/generateI18n $(pwd)/src"
1414
},
1515
"codingIdePackage": {
1616
"name": "access-url",
@@ -60,7 +60,7 @@
6060
"babel-runtime": "^6.11.6",
6161
"body-parser": "^1.15.2",
6262
"classnames": "^2.2.5",
63-
"codingSDK": "https://github.com/Coding/WebIDE-Plugin-SDK.git#0.0.1-alpha.10",
63+
"codingSDK": "https://github.com/Coding/WebIDE-Plugin-SDK.git#0.0.1-alpha.11",
6464
"cors": "^2.8.1",
6565
"express": "^4.14.0",
6666
"fs-promise": "^1.0.0",

src/manager.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import component, { store } from './app';
22
import APP from 'codingSDK/utils';
3-
import languagePool from '../i18n';
3+
4+
const languagePool = require('../i18n/index.json').reduce((p, v) => {
5+
p[v] = require(`../i18n/${v}/index`).default
6+
return p
7+
}, {})
48

59
export const global = new APP({
610
subscribeDataArray: ['GitState'],
@@ -11,7 +15,7 @@ export const global = new APP({
1115
const { injectComponent, i18n } = global;
1216
export default class {
1317
pluginWillMount() {
14-
console.log('this plugin will Moun');
18+
console.log('plugin will Mount');
1519
injectComponent.addComToSideBar('right', {
1620
text: i18n`global.sidebar`,
1721
icon: 'fa fa-external-link',
@@ -32,7 +36,7 @@ export default class {
3236
* @param {}
3337
*/
3438
pluginOnUnmount() {
35-
console.log('this plugin will UnMount');
39+
console.log('plugin will UnMount');
3640
}
3741
get component() {
3842
return component;

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,9 @@ code-point-at@^1.0.0:
13321332
version "1.1.0"
13331333
resolved "http://registry.npm.taobao.org/code-point-at/download/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
13341334

1335-
"codingSDK@https://github.com/Coding/WebIDE-Plugin-SDK.git#0.0.1-alpha.10":
1336-
version "0.0.1-alpha.10"
1337-
resolved "https://github.com/Coding/WebIDE-Plugin-SDK.git#e5cd66dcc6f229bd2f348750250d24386c3e1726"
1335+
"codingSDK@https://github.com/Coding/WebIDE-Plugin-SDK.git#0.0.1-alpha.11":
1336+
version "0.0.1-alpha.11"
1337+
resolved "https://github.com/Coding/WebIDE-Plugin-SDK.git#9a647837e82d8dad7c4108514c9dad7a4efdf9ab"
13381338
dependencies:
13391339
babel-preset-env "^1.1.8"
13401340
babel-runtime "^6.11.6"

0 commit comments

Comments
 (0)