Skip to content

Commit

Permalink
语言本地化测试
Browse files Browse the repository at this point in the history
  • Loading branch information
LY1806620741 committed Dec 30, 2023
1 parent f9e0ecd commit 66c822a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

```shell
# 使用管理模式
mkcert manager
automkcert auto
```

## 问答
Expand Down
2 changes: 2 additions & 0 deletions active.en.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
2 changes: 2 additions & 0 deletions active.zh.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion guide_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main_test
package main

import (
// main "jieshao/automkcert"
Expand Down
6 changes: 5 additions & 1 deletion i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion prompt.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 66c822a

Please sign in to comment.