mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-03-27 22:44:32 +08:00
为插件加载国际化文件
This commit is contained in:
@@ -17,6 +17,9 @@ module.exports =
|
||||
'linux', 'nodejs', 'php', 'python', 'rootpanel'
|
||||
]
|
||||
|
||||
plugin:
|
||||
availablePlugin: ['shadowsocks']
|
||||
|
||||
plans:
|
||||
all:
|
||||
t_name: '所有服务(默认)'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
8
core/plugin.coffee
Normal 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
|
||||
3
plugin/shadowsocks/locale/zh_CN.json
Normal file
3
plugin/shadowsocks/locale/zh_CN.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "ShadowSocks"
|
||||
}
|
||||
Reference in New Issue
Block a user