mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
add i18n translations
This commit is contained in:
@@ -55,5 +55,15 @@
|
||||
"Local Port": "Local Port",
|
||||
"Operation": "Operation",
|
||||
"Confirm": "Confirm",
|
||||
"Cancel": "Cancel"
|
||||
"Cancel": "Cancel",
|
||||
"Token Invalid": "Token invalid",
|
||||
"Operate Success": "Operate success",
|
||||
"Operate Failed": "Operate failed",
|
||||
"Should Check Proxy": "You should check at least one proxy",
|
||||
"Confirm Remove Proxy": "Confirm to remove proxy ?",
|
||||
"Operation Confirm": "Operation confirm",
|
||||
"Param Error": "Param error",
|
||||
"Frp Client Error": "Frp client error",
|
||||
"Proxy Exist,": "Proxy name exist",
|
||||
"Proxy Not Exist": "Proxy name not exist"
|
||||
}
|
||||
@@ -55,5 +55,15 @@
|
||||
"Local Port": "本地端口",
|
||||
"Operation": "操作",
|
||||
"Confirm": "确定",
|
||||
"Cancel": "取消"
|
||||
"Cancel": "取消",
|
||||
"Token Invalid": "登录信息无效",
|
||||
"Operate Success": "操作成功",
|
||||
"Operate Failed": "操作失败",
|
||||
"Should Check Proxy": "请选中需要操作的代理",
|
||||
"Confirm Remove Proxy": "确定删除代理?",
|
||||
"Operation Confirm": "操作确认",
|
||||
"Param Error": "参数错误",
|
||||
"Frp Client Error": "Frp客户端错误",
|
||||
"Proxy Exist": "代理名称重复",
|
||||
"Proxy Not Exist": "代理名称不存在"
|
||||
}
|
||||
@@ -16,7 +16,7 @@ var loadClientInfo = (function ($) {
|
||||
type: 'none'
|
||||
}).done(function (result) {
|
||||
if (result.success) {
|
||||
renderCommonInfo(result.data);
|
||||
renderClientInfo(result.data);
|
||||
} else {
|
||||
layui.layer.msg(result.message);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ var loadClientInfo = (function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
function renderCommonInfo(data) {
|
||||
function renderClientInfo(data) {
|
||||
data.tcp_mux = i18n[data.tcp_mux];
|
||||
data.tls_enable = i18n[data.tls_enable];
|
||||
var html = layui.laytpl($('#clientInfoTemplate').html()).render(data);
|
||||
|
||||
@@ -233,7 +233,7 @@ var loadProxyInfo = (function ($) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg('OperateSuccess', function (index) {
|
||||
layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
@@ -252,11 +252,11 @@ var loadProxyInfo = (function ($) {
|
||||
*/
|
||||
function batchRemovePopup(data) {
|
||||
if (data.length === 0) {
|
||||
layui.layer.msg('ShouldCheckProxy');
|
||||
layui.layer.msg(i18n['ShouldCheckProxy']);
|
||||
return;
|
||||
}
|
||||
layui.layer.confirm('ConfirmRemoveProxy', {
|
||||
title: 'OperationConfirm',
|
||||
layui.layer.confirm(i18n['ConfirmRemoveProxy'], {
|
||||
title: i18n['OperationConfirm'],
|
||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||
}, function (index) {
|
||||
var loading = layui.layer.load();
|
||||
@@ -269,7 +269,7 @@ var loadProxyInfo = (function ($) {
|
||||
if (result.success) {
|
||||
reloadTable();
|
||||
layui.layer.close(index);
|
||||
layui.layer.msg('OperateSuccess', function (index) {
|
||||
layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||
layui.layer.close(index);
|
||||
});
|
||||
} else {
|
||||
@@ -295,19 +295,16 @@ var loadProxyInfo = (function ($) {
|
||||
* @param result
|
||||
*/
|
||||
function errorMsg(result) {
|
||||
layui.layer.msg(result.message);
|
||||
// var reason = i18n['OtherError'];
|
||||
// if (result.code === 1)
|
||||
// reason = i18n['ParamError'];
|
||||
// else if (result.code === 2)
|
||||
// reason = i18n['SaveError'];
|
||||
// else if (result.code === 3)
|
||||
// reason = i18n['FrpServerError'];
|
||||
// else if (result.code === 4)
|
||||
// reason = i18n['ProxyExist'];
|
||||
// else if (result.code === 5)
|
||||
// reason = i18n['ProxyNotExist'];
|
||||
// layui.layer.msg(i18n['OperateFailed'] + ',' + reason)
|
||||
var reason = i18n['OtherError'];
|
||||
if (result.code === 1)
|
||||
reason = i18n['ParamError'];
|
||||
else if (result.code === 2)
|
||||
reason = i18n['FrpClientError'];
|
||||
else if (result.code === 3)
|
||||
reason = i18n['ProxyExist'];
|
||||
else if (result.code === 4)
|
||||
reason = i18n['ProxyNotExist'];
|
||||
layui.layer.msg(i18n['OperateFailed'] + ',' + reason)
|
||||
}
|
||||
|
||||
return loadProxyInfo;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
var http_port, https_port;
|
||||
(function ($) {
|
||||
$(function () {
|
||||
function init() {
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<input type="hidden" name="type">
|
||||
<input type="hidden" name="${ .oldNameKey }" id="oldName">
|
||||
<input type="hidden" name="${ .OldNameKey }" id="oldName">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${ .ProxyName }</label>
|
||||
|
||||
@@ -57,7 +57,7 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
context.HTML(http.StatusOK, "index.html", gin.H{
|
||||
"version": c.Version,
|
||||
"oldNameKey": oldNameKey,
|
||||
"OldNameKey": OldNameKey,
|
||||
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
||||
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
||||
"ClientInfo": ginI18n.MustGetMessage(context, "Client Info"),
|
||||
@@ -103,22 +103,32 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
||||
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||
return func(context *gin.Context) {
|
||||
context.JSON(http.StatusOK, gin.H{
|
||||
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
||||
"true": ginI18n.MustGetMessage(context, "true"),
|
||||
"false": ginI18n.MustGetMessage(context, "false"),
|
||||
"Name": ginI18n.MustGetMessage(context, "Name"),
|
||||
"Type": ginI18n.MustGetMessage(context, "Type"),
|
||||
"LocalAddress": ginI18n.MustGetMessage(context, "Local Address"),
|
||||
"Plugin": ginI18n.MustGetMessage(context, "Plugin"),
|
||||
"RemoteAddress": ginI18n.MustGetMessage(context, "Remote Address"),
|
||||
"Status": ginI18n.MustGetMessage(context, "Status"),
|
||||
"Info": ginI18n.MustGetMessage(context, "Info"),
|
||||
"running": ginI18n.MustGetMessage(context, "running"),
|
||||
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
||||
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
||||
"Operation": ginI18n.MustGetMessage(context, "Operation"),
|
||||
"Confirm": ginI18n.MustGetMessage(context, "Confirm"),
|
||||
"Cancel": ginI18n.MustGetMessage(context, "Cancel"),
|
||||
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
||||
"true": ginI18n.MustGetMessage(context, "true"),
|
||||
"false": ginI18n.MustGetMessage(context, "false"),
|
||||
"Name": ginI18n.MustGetMessage(context, "Name"),
|
||||
"Type": ginI18n.MustGetMessage(context, "Type"),
|
||||
"LocalAddress": ginI18n.MustGetMessage(context, "Local Address"),
|
||||
"Plugin": ginI18n.MustGetMessage(context, "Plugin"),
|
||||
"RemoteAddress": ginI18n.MustGetMessage(context, "Remote Address"),
|
||||
"Status": ginI18n.MustGetMessage(context, "Status"),
|
||||
"Info": ginI18n.MustGetMessage(context, "Info"),
|
||||
"running": ginI18n.MustGetMessage(context, "running"),
|
||||
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
||||
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
||||
"Operation": ginI18n.MustGetMessage(context, "Operation"),
|
||||
"Confirm": ginI18n.MustGetMessage(context, "Confirm"),
|
||||
"Cancel": ginI18n.MustGetMessage(context, "Cancel"),
|
||||
"TokenInvalid": ginI18n.MustGetMessage(context, "Token Invalid"),
|
||||
"OperateSuccess": ginI18n.MustGetMessage(context, "Operate Success"),
|
||||
"OperateFailed": ginI18n.MustGetMessage(context, "Operate Failed"),
|
||||
"ShouldCheckProxy": ginI18n.MustGetMessage(context, "Should Check Proxy"),
|
||||
"ConfirmRemoveProxy": ginI18n.MustGetMessage(context, "Confirm Remove Proxy"),
|
||||
"OperationConfirm": ginI18n.MustGetMessage(context, "Operation Confirm"),
|
||||
"ParamError": ginI18n.MustGetMessage(context, "Param Error"),
|
||||
"FrpClientError": ginI18n.MustGetMessage(context, "Frp Client Error"),
|
||||
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
|
||||
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not Exist"),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -143,7 +153,7 @@ func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
name := proxy[nameKey]
|
||||
name := proxy[NameKey]
|
||||
|
||||
if trimString(name) == "" {
|
||||
response.Success = false
|
||||
@@ -163,13 +173,13 @@ func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
delete(proxy, nameKey)
|
||||
delete(proxy, NameKey)
|
||||
clientProxies[name] = proxy
|
||||
|
||||
res := c.UpdateFrpcConfig()
|
||||
if !res.Success {
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Code = res.Code
|
||||
response.Message = fmt.Sprintf("proxy add failed, error : %v", res.Message)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
@@ -200,8 +210,8 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
oldName := proxy[oldNameKey]
|
||||
name := proxy[nameKey]
|
||||
oldName := proxy[OldNameKey]
|
||||
name := proxy[NameKey]
|
||||
|
||||
if trimString(oldName) == "" || trimString(name) == "" {
|
||||
response.Success = false
|
||||
@@ -212,6 +222,15 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if _, exist := clientProxies[oldName]; !exist {
|
||||
response.Success = false
|
||||
response.Code = ProxyNotExist
|
||||
response.Message = fmt.Sprintf("proxy update failed, proxy not exist")
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
return
|
||||
}
|
||||
|
||||
if oldName != name {
|
||||
if _, exist := clientProxies[name]; exist {
|
||||
response.Success = false
|
||||
@@ -223,15 +242,15 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
delete(proxy, nameKey)
|
||||
delete(proxy, oldNameKey)
|
||||
delete(proxy, NameKey)
|
||||
delete(proxy, OldNameKey)
|
||||
delete(clientProxies, oldName)
|
||||
clientProxies[name] = proxy
|
||||
|
||||
res := c.UpdateFrpcConfig()
|
||||
if !res.Success {
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Code = res.Code
|
||||
response.Message = fmt.Sprintf("user update failed, error : %v", res.Message)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
@@ -264,7 +283,7 @@ func (c *HandleController) MakeRemoveProxyFunc() func(context *gin.Context) {
|
||||
|
||||
tempProxyNames := make([]string, len(proxies))
|
||||
for index, proxy := range proxies {
|
||||
name := proxy[nameKey]
|
||||
name := proxy[NameKey]
|
||||
|
||||
if trimString(name) == "" {
|
||||
response.Success = false
|
||||
@@ -294,7 +313,7 @@ func (c *HandleController) MakeRemoveProxyFunc() func(context *gin.Context) {
|
||||
res := c.UpdateFrpcConfig()
|
||||
if !res.Success {
|
||||
response.Success = false
|
||||
response.Code = SaveError
|
||||
response.Code = res.Code
|
||||
response.Message = fmt.Sprintf("proxy remvoe failed, error : %v", res.Message)
|
||||
log.Printf(response.Message)
|
||||
context.JSON(http.StatusOK, &response)
|
||||
@@ -314,7 +333,7 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
||||
response, err := c.getClientResponse(request, c.buildClient())
|
||||
|
||||
if err != nil {
|
||||
res.Code = FrpServerError
|
||||
res.Code = FrpClientError
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
log.Print(err)
|
||||
@@ -348,7 +367,7 @@ func (c *HandleController) UpdateFrpcConfig() ProxyResponse {
|
||||
response, err := c.getClientResponse(request, c.buildClient())
|
||||
|
||||
if err != nil {
|
||||
res.Code = FrpServerError
|
||||
res.Code = FrpClientError
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
log.Print(err)
|
||||
@@ -368,7 +387,7 @@ func (c *HandleController) ReloadFrpcConfig(res *ProxyResponse) {
|
||||
response, err := c.getClientResponse(request, c.buildClient())
|
||||
|
||||
if err != nil {
|
||||
res.Code = FrpServerError
|
||||
res.Code = FrpClientError
|
||||
res.Success = false
|
||||
res.Message = err.Error()
|
||||
log.Print(err)
|
||||
|
||||
@@ -128,7 +128,7 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
|
||||
currentProxies[name] = section
|
||||
}
|
||||
clientProxies[name] = section
|
||||
delete(clientProxies[name], nameKey)
|
||||
delete(clientProxies[name], NameKey)
|
||||
}
|
||||
|
||||
if proxyType == "none" {
|
||||
|
||||
@@ -7,24 +7,14 @@ import (
|
||||
const (
|
||||
Success int = iota
|
||||
ParamError
|
||||
SaveError
|
||||
FrpServerError
|
||||
FrpClientError
|
||||
ProxyExist
|
||||
ProxyNotExist
|
||||
)
|
||||
|
||||
const (
|
||||
ProxyAdd int = iota
|
||||
ProxyUpdate
|
||||
ProxyRemove
|
||||
)
|
||||
|
||||
const (
|
||||
nameKey = "name"
|
||||
oldNameKey = "_old_name"
|
||||
)
|
||||
|
||||
const (
|
||||
NameKey = "name"
|
||||
OldNameKey = "_old_name"
|
||||
SessionName = "GOSESSION"
|
||||
AuthName = "_PANEL_AUTH"
|
||||
LoginUrl = "/login"
|
||||
|
||||
Reference in New Issue
Block a user