From 66c822a856c085ae78da84b693b27290d97e8ef9 Mon Sep 17 00:00:00 2001 From: biewang <1806620741@qq.com> Date: Sat, 30 Dec 2023 17:14:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E8=A8=80=E6=9C=AC=E5=9C=B0=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- active.en.toml | 2 ++ active.zh.toml | 2 ++ go.mod | 1 + go.sum | 2 ++ guide_test.go | 2 +- i18n.go | 6 +++++- prompt.go | 2 +- 8 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6defcec..22060dd 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ```shell # 使用管理模式 -mkcert manager +automkcert auto ``` ## 问答 diff --git a/active.en.toml b/active.en.toml index bd0cea6..ab137aa 100644 --- a/active.en.toml +++ b/active.en.toml @@ -1,3 +1,5 @@ +errUnknownGroupCommand = "err. Unknown command \"{{.Name}}\"" +help = "Usage of {{.Name}}:\n\t\t\n $ {{.Name}} auto\n use guide\n\n $ {{.Name}} mkcert\n use mkcert, the same as mkcert's usage.\n\n" moreOptions = "For more options, run \"mkcert -help\"." shortUsage = "Usage of mkcert:\n\n\t$ mkcert -install\n\tInstall the local CA in the system trust store.\n\n\t$ mkcert example.org\n\tGenerate \"example.org.pem\" and \"example.org-key.pem\".\n\n\t$ mkcert example.com myapp.dev localhost 127.0.0.1 ::1\n\tGenerate \"example.com+4.pem\" and \"example.com+4-key.pem\".\n\n\t$ mkcert \"*.example.it\"\n\tGenerate \"_wildcard.example.it.pem\" and \"_wildcard.example.it-key.pem\".\n\n\t$ mkcert -uninstall\n\tUninstall the local CA (but do not delete it).\n\n" diff --git a/active.zh.toml b/active.zh.toml index 6409d52..fdee24b 100644 --- a/active.zh.toml +++ b/active.zh.toml @@ -1,3 +1,5 @@ +errUnknownGroupCommand = "错误. 未知的命令 \"{{.Name}}\"" +help = "{{.Name}}的用法:\n\t\t\n $ {{.Name}} auto\n 使用向导\n\n $ {{.Name}} mkcert\n 使用 mkcert, 跟原版 mkcert 用法一致.\n\n" moreOptions = "有关更多选项,请运行“mkcert-help”。" shortUsage = "mkcert 的用法:\n\n\t$ mkcert -install\n\t在系统信任存储中安装本地 CA。\n\n\t$ mkcert example.org\n\t生成 \"example.org.pem\" 和 \"example.org-key.pem\"。\n\n\t$ mkcert example.com myapp.dev localhost 127.0.0.1 ::1\n\t生成 \"example.com+4.pem\" 和 \"example.com+4-key.pem\"。\n\n\t$ mkcert \"*.example.it\"\n\t生成 \"_wildcard.example.it.pem\" 和 \" _wildcard.example.it-key.pem\"。\n\n\t$ mkcert -uninstall\n\t卸载本地 CA(但不删除它)。\n\n" diff --git a/go.mod b/go.mod index 90ca7af..e6a6efb 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( require ( github.com/AlecAivazis/survey/v2 v2.3.7 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect + github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect github.com/golang/mock v1.6.0 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect diff --git a/go.sum b/go.sum index 843118b..c69cd8c 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:tuijfIjZyjZaHq9xDUh0tNitwXshJpbLkqMOJv4H3do= +github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/guide_test.go b/guide_test.go index 52ddad4..8509697 100644 --- a/guide_test.go +++ b/guide_test.go @@ -1,4 +1,4 @@ -package main_test +package main import ( // main "jieshao/automkcert" diff --git a/i18n.go b/i18n.go index 939a8f7..4d5c7b3 100644 --- a/i18n.go +++ b/i18n.go @@ -4,6 +4,7 @@ import ( "embed" "github.com/BurntSushi/toml" + "github.com/cloudfoundry/jibber_jabber" "github.com/nicksnyder/go-i18n/v2/i18n" "golang.org/x/text/language" ) @@ -27,13 +28,16 @@ var i18nText I18nText var i18nMkcertText I18nMkcertText func init() { + userLanguage, _ := jibber_jabber.DetectLanguage() + // println("Language:", userLanguage) + userTag := language.MustParse(userLanguage) bundle := i18n.NewBundle(language.English) bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) bundle.LoadMessageFileFS(LocaleFS, "active.zh.toml") tag, _, _ := language.NewMatcher([]language.Tag{ language.English, language.Chinese, - }).Match() + }).Match(userTag) localizer = i18n.NewLocalizer(bundle, tag.String()) i18nText.help = localizer.MustLocalize(&i18n.LocalizeConfig{ diff --git a/prompt.go b/prompt.go index ce356bc..fa53237 100644 --- a/prompt.go +++ b/prompt.go @@ -1,6 +1,6 @@ package main -//go:generate mockgen -destination mock_prompt_test.go -package main_test -source prompt.go Prompt +//go:generate mockgen -destination mock_prompt_test.go -package main -source prompt.go Prompt import ( "errors"