From f31e687b3825aed36de7d1a585bb8161003134e0 Mon Sep 17 00:00:00 2001 From: jysperm Date: Mon, 28 Apr 2014 01:58:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E6=8F=92=E4=BB=B6=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.coffee | 3 +++ core/i18n.coffee | 4 ++++ core/index.coffee | 3 +++ core/plugin.coffee | 8 ++++++++ plugin/shadowsocks/locale/zh_CN.json | 3 +++ 5 files changed, 21 insertions(+) create mode 100644 core/plugin.coffee create mode 100644 plugin/shadowsocks/locale/zh_CN.json diff --git a/core/config.coffee b/core/config.coffee index 31315fa..6619b33 100644 --- a/core/config.coffee +++ b/core/config.coffee @@ -17,6 +17,9 @@ module.exports = 'linux', 'nodejs', 'php', 'python', 'rootpanel' ] + plugin: + availablePlugin: ['shadowsocks'] + plans: all: t_name: '所有服务(默认)' diff --git a/core/i18n.coffee b/core/i18n.coffee index fbbcc44..b685e8e 100644 --- a/core/i18n.coffee +++ b/core/i18n.coffee @@ -13,6 +13,10 @@ exports.load = (path) -> for lang in options.available_language data[lang] = JSON.parse fs.readFileSync((require 'path').join(path, "#{lang}.json"), 'utf8') +exports.loadPlugin = (path, name) -> + for lang in options.available_language + data[lang]['plugins'][name] = JSON.parse fs.readFileSync((require 'path').join(path, "#{lang}.json"), 'utf8') + exports.translate = (name, lang) -> unless lang lang = options.default_language diff --git a/core/index.coffee b/core/index.coffee index a6fd721..7dd87ca 100644 --- a/core/index.coffee +++ b/core/index.coffee @@ -62,6 +62,9 @@ exports.runWebServer = -> api = require './api' api.bind app + plugin = require './plugin' + plugin.loadPlugins() + app.listen config.web.port unless module.parent diff --git a/core/plugin.coffee b/core/plugin.coffee new file mode 100644 index 0000000..664e562 --- /dev/null +++ b/core/plugin.coffee @@ -0,0 +1,8 @@ +path = require 'path' + +i18n = require './i18n' +config = require './config' + +exports.loadPlugins = -> + for name in config.plugin.availablePlugin + i18n.loadPlugin path.join(__dirname, "../plugin/#{name}/locale"), name diff --git a/plugin/shadowsocks/locale/zh_CN.json b/plugin/shadowsocks/locale/zh_CN.json new file mode 100644 index 0000000..05c7a64 --- /dev/null +++ b/plugin/shadowsocks/locale/zh_CN.json @@ -0,0 +1,3 @@ +{ + "name": "ShadowSocks" +}