部分中文转换为多语言代号

This commit is contained in:
GoEdgeLab
2023-06-28 16:18:52 +08:00
parent 97fe91c7b0
commit 0aae6a5beb
25 changed files with 195 additions and 125 deletions

View File

@@ -3,6 +3,7 @@ package cluster
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -27,12 +28,12 @@ func (this *CreateBatchAction) RunGet(params struct {
}) {
leftMenuItems := []maps.Map{
{
"name": "单个创建",
"name": this.Lang(codes.AdminNodeMenuCreateSingleNode),
"url": "/clusters/cluster/createNode?clusterId=" + strconv.FormatInt(params.ClusterId, 10),
"isActive": false,
},
{
"name": "批量创建",
"name": this.Lang(codes.AdminNodeMenuCreateMultipleNodes),
"url": "/clusters/cluster/createBatch?clusterId=" + strconv.FormatInt(params.ClusterId, 10),
"isActive": true,
},

View File

@@ -7,6 +7,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -37,12 +38,12 @@ func (this *CreateNodeAction) RunGet(params struct {
var leftMenuItems = []maps.Map{
{
"name": "单个创建",
"name": this.Lang(codes.AdminNodeMenuCreateSingleNode),
"url": "/clusters/cluster/createNode?clusterId=" + strconv.FormatInt(params.ClusterId, 10),
"isActive": true,
},
{
"name": "批量创建",
"name": this.Lang(codes.AdminNodeMenuCreateMultipleNodes),
"url": "/clusters/cluster/createBatch?clusterId=" + strconv.FormatInt(params.ClusterId, 10),
"isActive": false,
},

View File

@@ -19,7 +19,7 @@ func (this *InstallManualAction) Init() {
func (this *InstallManualAction) RunGet(params struct {
ClusterId int64
}) {
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "manual")
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "manual", this.LangCode())
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithNodeClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
if err != nil {

View File

@@ -19,7 +19,7 @@ func (this *InstallNodesAction) Init() {
func (this *InstallNodesAction) RunGet(params struct {
ClusterId int64
}) {
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "register")
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "register", this.LangCode())
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: params.ClusterId})
if err != nil {

View File

@@ -21,7 +21,7 @@ func (this *InstallRemoteAction) Init() {
func (this *InstallRemoteAction) RunGet(params struct {
ClusterId int64
}) {
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "install")
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "install", this.LangCode())
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithNodeClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
if err != nil {

View File

@@ -5,6 +5,7 @@ package nodeutils
import (
"errors"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
@@ -57,24 +58,24 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod
var menuItems = []maps.Map{
{
"name": "基础设置",
"name": parentAction.Lang(codes.AdminNodeMenuSettingBasic),
"url": prefix + "/update?" + query,
"isActive": menuItem == "basic",
},
{
"name": "DNS设置",
"name": parentAction.Lang(codes.AdminNodeMenuSettingDNS),
"url": prefix + "/settings/dns?" + query,
"isActive": menuItem == "dns",
"isOn": info.HasDNSInfo,
},
{
"name": "缓存设置",
"name": parentAction.Lang(codes.AdminNodeMenuSettingCache),
"url": prefix + "/settings/cache?" + query,
"isActive": menuItem == "cache",
"isOn": info.HasCacheInfo,
},
{
"name": "DDoS防护",
"name": parentAction.Lang(codes.AdminNodeMenuSettingDDoSProtection),
"url": prefix + "/settings/ddos-protection?" + query,
"isActive": menuItem == "ddosProtection",
"isOn": info.HasDDoSProtection,
@@ -84,16 +85,16 @@ func InitNodeInfo(parentAction *actionutils.ParentAction, nodeId int64) (*pb.Nod
"url": "",
},
}
menuItems = filterMenuItems(menuItems, menuItem, prefix, query, info)
menuItems = filterMenuItems(menuItems, menuItem, prefix, query, info, parentAction.LangCode())
menuItems = append(menuItems, []maps.Map{
{
"name": "SSH设置",
"name": parentAction.Lang(codes.AdminNodeMenuSettingSSH),
"url": prefix + "/settings/ssh?" + query,
"isActive": menuItem == "ssh",
"isOn": info.HasSSH,
},
{
"name": "系统设置",
"name": parentAction.Lang(codes.AdminNodeMenuSettingSystem),
"url": prefix + "/settings/system?" + query,
"isActive": menuItem == "system",
"isOn": info.HasSystemSettings,

View File

@@ -8,6 +8,6 @@ import (
"github.com/iwind/TeaGo/maps"
)
func filterMenuItems(menuItems []maps.Map, menuItem string, prefix string, query string, info *pb.FindEnabledNodeConfigInfoResponse) []maps.Map {
func filterMenuItems(menuItems []maps.Map, menuItem string, prefix string, query string, info *pb.FindEnabledNodeConfigInfoResponse, langCode string) []maps.Map {
return menuItems
}

View File

@@ -6,6 +6,7 @@ import (
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/logs"
@@ -290,7 +291,7 @@ func (this *NodesAction) RunGet(params struct {
groupMaps = append([]maps.Map{
{
"id": -1,
"name": "[未分组](" + types.String(countUngroupNodes) + ")",
"name": "[" + this.Lang(codes.AdminNodeUngroupedLabel)+ "](" + types.String(countUngroupNodes) + ")",
"countNodes": countUngroupNodes,
},
}, groupMaps...)

View File

@@ -21,7 +21,7 @@ func (this *UpgradeRemoteAction) Init() {
func (this *UpgradeRemoteAction) RunGet(params struct {
ClusterId int64
}) {
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "upgrade")
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "upgrade", this.LangCode())
nodes := []maps.Map{}
resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithNodeClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})

View File

@@ -4,13 +4,14 @@ import (
"context"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"strconv"
)
// LeftMenuItemsForInstall 安装升级相关的左侧菜单
func LeftMenuItemsForInstall(ctx context.Context, clusterId int64, selectedItem string) []maps.Map {
func LeftMenuItemsForInstall(ctx context.Context, clusterId int64, selectedItem string, langCode string) []maps.Map {
rpcClient, _ := rpc.SharedRPC()
countNotInstalled := int64(0)
countUpgrade := int64(0)
@@ -31,22 +32,22 @@ func LeftMenuItemsForInstall(ctx context.Context, clusterId int64, selectedItem
return []maps.Map{
{
"name": "手动安装",
"name": langs.Message(langCode, codes.AdminNodeMenuInstallManually),
"url": "/clusters/cluster/installManual?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "manual",
},
{
"name": "自动注册",
"name": langs.Message(langCode, codes.AdminNodeMenuInstallAutoRegister),
"url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "register",
},
{
"name": "远程安装(" + strconv.FormatInt(countNotInstalled, 10) + ")",
"name": langs.Message(langCode, codes.AdminNodeMenuInstallRemote, countNotInstalled),
"url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "install",
},
{
"name": "远程升级(" + strconv.FormatInt(countUpgrade, 10) + ")",
"name": langs.Message(langCode, codes.AdminNodeMenuInstallRemoteUpgrade, countUpgrade),
"url": "/clusters/cluster/upgradeRemote?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "upgrade",
},