为插件加载国际化文件

This commit is contained in:
jysperm
2014-04-28 01:58:08 +08:00
parent 3d4505c7a4
commit f31e687b38
5 changed files with 21 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ module.exports =
'linux', 'nodejs', 'php', 'python', 'rootpanel'
]
plugin:
availablePlugin: ['shadowsocks']
plans:
all:
t_name: '所有服务(默认)'

View File

@@ -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

View File

@@ -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

8
core/plugin.coffee Normal file
View File

@@ -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

View File

@@ -0,0 +1,3 @@
{
"name": "ShadowSocks"
}