From 5b92b75090e16085cd0b0d98890bfde600f82907 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:43:14 +0800 Subject: [PATCH] feat(cmd): Add internationalization for the output of the 1pctl version (#7263) --- backend/i18n/lang/en.yaml | 3 ++- backend/i18n/lang/fa.yaml | 3 ++- backend/i18n/lang/pt.yaml | 3 ++- backend/i18n/lang/zh-Hant.yaml | 3 ++- backend/i18n/lang/zh.yaml | 3 ++- cmd/server/cmd/version.go | 6 +++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index ea2e2b3f2175..39b80c6f9987 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -278,5 +278,6 @@ UpdatePortFirewallReload: "Failed to reload the firewall, {{ .err }}, please man UserInfo: "Get panel information" UserInfoAddr: "Panel address: " UserInfoPassHelp: "Tip: To change the password, you can execute the command: " -SystemVersion: "Get system version information" DBConnErr: "Error: Failed to initialize database connection, {{ .err }}" +SystemVersion: "version: " +SystemMode: "mode: " diff --git a/backend/i18n/lang/fa.yaml b/backend/i18n/lang/fa.yaml index 612b34aabb66..da66e965d6fb 100644 --- a/backend/i18n/lang/fa.yaml +++ b/backend/i18n/lang/fa.yaml @@ -58,5 +58,6 @@ UpdatePortFirewallReload: "Reload firewall namovaffagh bud, {{ .err }}, lotfan f UserInfo: "Daryaft etela'at-e panel" UserInfoAddr: "Adres-e panel: " UserInfoPassHelp: "Nokte: baraye taghiri ramz, mitavanid dastur zir ra anjam dahid: " -SystemVersion: "Daryaft etela'at-e version system" DBConnErr: "Khatta: etesal be database namovaffagh bud, {{ .err }}" +SystemVersion: "noskhe: " +SystemMode: "halat: " diff --git a/backend/i18n/lang/pt.yaml b/backend/i18n/lang/pt.yaml index a4eae1f836ad..f42f9f515a88 100644 --- a/backend/i18n/lang/pt.yaml +++ b/backend/i18n/lang/pt.yaml @@ -58,5 +58,6 @@ UpdatePortFirewallReload: "Falha ao recarregar o firewall, {{ .err }}, recarregu UserInfo: "Obter informações do painel" UserInfoAddr: "Endereço do painel: " UserInfoPassHelp: "Dica: Para alterar a senha, execute o comando: " -SystemVersion: "Obter informações da versão do sistema" DBConnErr: "Erro: Falha ao inicializar conexão com o banco de dados, {{ .err }}" +SystemVersion: "versão: " +SystemMode: "modo: " \ No newline at end of file diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index c20a19f0af33..1e4cf4af95ad 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -278,5 +278,6 @@ UpdatePortFirewallReload: "防火牆重載失敗,{{ .err }},請您手動重 UserInfo: "獲取面板信息" UserInfoAddr: "面板地址:" UserInfoPassHelp: "提示:修改密碼可執行命令:" -SystemVersion: "獲取系統版本信息" DBConnErr: "錯誤:初始化資料庫連接失敗,{{ .err }}" +SystemVersion: "版本:" +SystemMode: "模式:" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index 7d152cbdc7df..72fabe4c7435 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -278,5 +278,6 @@ UpdatePortFirewallReload: "防火墙重载失败,{{ .err }},请您手动重 UserInfo: "获取面板信息" UserInfoAddr: "面板地址:" UserInfoPassHelp: "提示:修改密码可执行命令:" -SystemVersion: "获取系统版本信息" DBConnErr: "错误:初始化数据库连接失败,{{ .err }}" +SystemVersion: "版本:" +SystemMode: "模式:" diff --git a/cmd/server/cmd/version.go b/cmd/server/cmd/version.go index daa89993e4d5..3cb62178eac4 100644 --- a/cmd/server/cmd/version.go +++ b/cmd/server/cmd/version.go @@ -29,12 +29,12 @@ var versionCmd = &cobra.Command{ } version := getSettingByKey(db, "SystemVersion") - fmt.Printf("1panel version: %s\n", version) + fmt.Println(i18n.GetMsgByKeyForCmd("SystemVersion") + version) config := configs.ServerConfig{} if err := yaml.Unmarshal(conf.AppYaml, &config); err != nil { - return fmt.Errorf("unmarshal conf.App.Yaml failed, errL %v", err) + return fmt.Errorf("unmarshal conf.App.Yaml failed, err: %v", err) } else { - fmt.Printf("mode: %s\n", config.System.Mode) + fmt.Println(i18n.GetMsgByKeyForCmd("SystemMode") + config.System.Mode) } return nil },