1- # go-i18n ![ Build status] ( https://github.com/nicksnyder/go-i18n/workflows/Build/badge.svg ) [ ![ Report card] ( https://goreportcard.com/badge/github.com/nicksnyder/go-i18n )] ( https://goreportcard.com/report/github.com/nicksnyder/go-i18n ) [ ![ codecov] ( https://codecov.io/gh/nicksnyder/go-i18n/branch/master/graph/badge.svg )] ( https://codecov.io/gh/nicksnyder/go-i18n ) [ ![ Sourcegraph] ( https://sourcegraph.com/github.com/nicksnyder/go-i18n/-/badge.svg )] ( https://sourcegraph.com/github.com/nicksnyder/go-i18n?badge )
1+ # go-i18n
2+ ![ Build status] ( https://github.com/nicksnyder/go-i18n/workflows/Build/badge.svg ) [ ![ Report card] ( https://goreportcard.com/badge/github.com/nicksnyder/go-i18n/v2 )] ( https://goreportcard.com/report/github.com/nicksnyder/go-i18n/v2 ) [ ![ codecov] ( https://codecov.io/gh/nicksnyder/go-i18n/graph/badge.svg?token=A9aMfR9vxG )] ( https://codecov.io/gh/nicksnyder/go-i18n ) [ ![ Sourcegraph] ( https://sourcegraph.com/github.com/nicksnyder/go-i18n/-/badge.svg )] ( https://sourcegraph.com/github.com/nicksnyder/go-i18n?badge )
23
3- go-i18n 是一个帮助您将 Go 程序翻译成多种语言的 Go [ 包] ( #package-i18n ) 和 [ 命令] ( #command-goi18n ) 。
4+ go-i18n 是一个帮助您将 Go 程序翻译成多种语言的 Go [ 包] ( #package-i18n ) 和 [ 命令] ( #command-goi18n ) 。
45
5- - 支持 [ Unicode Common Locale Data Repository (CLDR)] ( https://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html ) 中所有 200 多种语言的 [ 复数字符] ( http://cldr.unicode.org/index/cldr-spec/plural-rules ) 。
6- - 代码和测试是从 [ CLDR 数据] ( http://cldr.unicode.org/index/downloads ) 中 [ 自动生成] ( https://github.com/nicksnyder/go-i18n/tree/main/v2/internal/plural/codegen ) 的。
6+ - 支持 [ Unicode Common Locale Data Repository (CLDR)] ( https://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html )
7+ 中所有 200 多种语言的[ 复数字符串] ( http://cldr.unicode.org/index/cldr-spec/plural-rules ) 。
8+ - 代码和测试是基于 [ CLDR 数据] ( http://cldr.unicode.org/index/downloads ) [ 自动生成] ( https://github.com/nicksnyder/go-i18n/tree/main/internal/plural/codegen ) 的。
79- 使用 [ text/template] ( http://golang.org/pkg/text/template/ ) 语法支持带有命名变量的字符串。
8- - 支持任何格式的消息文件 (例如:JSON、TOML、YAML)。
10+ - 支持所有格式的消息文件 (例如:JSON、TOML、YAML)。
911
1012<strong align =" center " >
1113<samp >
@@ -15,11 +17,11 @@ go-i18n 是一个帮助您将 Go 程序翻译成多种语言的 Go [包](#packag
1517</samp >
1618</strong >
1719
18- ## Package i18n
20+ ## i18n 包
1921
20- [ ![ GoDoc ] ( https://godoc.org/ github.com/nicksnyder/go-i18n?status .svg )] ( https://godoc.org /github.com/nicksnyder/go-i18n/v2/i18n )
22+ [ ![ Go Reference ] ( https://pkg.go.dev/badge/ github.com/nicksnyder/go-i18n/v2/i18n .svg )] ( https://pkg.go.dev /github.com/nicksnyder/go-i18n/v2/i18n )
2123
22- i18n 包支持根据一组语言环境首选项查找消息 。
24+ i18n 包支持根据一组语言环境首选项来查找消息 。
2325
2426``` go
2527import " github.com/nicksnyder/go-i18n/v2/i18n"
@@ -31,7 +33,7 @@ import "github.com/nicksnyder/go-i18n/v2/i18n"
3133bundle := i18n.NewBundle (language.English )
3234```
3335
34- 在初始化期间将翻译加载到您的 bundle 中。
36+ 在初始化时,将翻译加载到你的 Bundle 中。
3537
3638``` go
3739bundle.RegisterUnmarshalFunc (" toml" , toml.Unmarshal )
@@ -47,7 +49,7 @@ bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
4749bundle.LoadMessageFileFS (LocaleFS, " locale.es.toml" )
4850```
4951
50- 创建一个 Localizer 以用于一组语言首选项 。
52+ 创建一个 Localizer 以便用于一组首选语言 。
5153
5254``` go
5355func (w http .ResponseWriter , r *http .Request ) {
@@ -57,7 +59,7 @@ func(w http.ResponseWriter, r *http.Request) {
5759}
5860```
5961
60- 使用 Localizer 查找消息。
62+ 使用此 Localizer 查找消息。
6163
6264``` go
6365localizer.Localize (&i18n.LocalizeConfig {
@@ -71,14 +73,14 @@ localizer.Localize(&i18n.LocalizeConfig{
7173 " Count" : 2 ,
7274 },
7375 PluralCount : 2 ,
74- }) // Nick has 2 cats.
76+ }) // Nick 有两只猫
7577```
7678
7779## goi18n 命令
7880
79- [ ![ GoDoc ] ( https://godoc.org/ github.com/nicksnyder/go-i18n?status .svg )] ( https://godoc.org /github.com/nicksnyder/go-i18n/v2/goi18n )
81+ [ ![ Go Reference ] ( https://pkg.go.dev/badge/ github.com/nicksnyder/go-i18n/v2/goi18n .svg )] ( https://pkg.go.dev /github.com/nicksnyder/go-i18n/v2/goi18n )
8082
81- goi18n 命令管理 i18n 包使用的消息文件 。
83+ goi18n 命令管理 i18n 包所使用的消息文件 。
8284
8385```
8486go install -v github.com/nicksnyder/go-i18n/v2/goi18n@latest
@@ -87,7 +89,7 @@ goi18n -help
8789
8890### 提取消息
8991
90- 使用 ` goi18n extract ` 将 Go 源文件中的所有 i18n.Message 结构文字提取到消息文件中以进行翻译 。
92+ 使用 ` goi18n extract ` 将 Go 源文件中的所有 i18n.Message 结构中的文字提取到消息文件中以进行翻译 。
9193
9294``` toml
9395# active.en.toml
@@ -99,8 +101,8 @@ other = "{{.Name}} has {{.Count}} cats."
99101
100102### 翻译一种新语言
101103
102- 1 . 为您要添加的语言创建一个空消息文件 (例如:` translate.es.toml ` )。
103- 2 . 运行 ` goi18n merge active.en.toml translate.es.toml ` 以填充 ` translate.es.toml ` 要翻译的消息 。
104+ 1 . 为你要添加的语言创建一个空的消息文件 (例如:` translate.es.toml ` )。
105+ 2 . 运行 ` goi18n merge active.en.toml translate.es.toml ` 以将要翻译的消息填充到 ` translate.es.toml ` 中 。
104106
105107 ``` toml
106108 # translate.es.toml
@@ -109,7 +111,7 @@ other = "{{.Name}} has {{.Count}} cats."
109111 other = " Hello {{.Name}}"
110112 ```
111113
112- 3 . 翻译完成 ` translate.es.toml ` 后 ,将其重命名为 `active.es.toml` `。
114+ 3 . 完成 ` translate.es.toml ` 的翻译之后 ,将其重命名为 ` active.es.toml ` 。
113115
114116 ``` toml
115117 # active.es.toml
@@ -118,7 +120,7 @@ other = "{{.Name}} has {{.Count}} cats."
118120 other = " Hola {{.Name}}"
119121 ```
120122
121- 4 . 加载 ` active.es.toml ` 到您的 bundle 中。
123+ 4 . 加载 ` active.es.toml ` 到你的 Bundle 中。
122124
123125 ``` go
124126 bundle.RegisterUnmarshalFunc (" toml" , toml.Unmarshal )
@@ -127,19 +129,21 @@ other = "{{.Name}} has {{.Count}} cats."
127129
128130### 翻译新消息
129131
130- 如果您在程序中添加了新消息 :
132+ 如果你在程序中添加了新消息 :
131133
132- 1 . 运行 ` goi18n extract ` 以使用新消息更新 ` active.en.toml ` 。
133- 2 . 运行 ` goi18n merge active.*.toml ` 以生成更新的 ` translate.*.toml ` 文件。
134+ 1 . 运行 ` goi18n extract ` 以将新的消息更新到 ` active.en.toml ` 。
135+ 2 . 运行 ` goi18n merge active.*.toml ` 以生成更新后的 ` translate.*.toml ` 文件。
1341363 . 翻译 ` translate.*.toml ` 文件中的所有消息。
135- 4 . 运行 ` goi18n merge active.*.toml translate.*.toml ` 将翻译后的消息合并到 active 消息文件中。
137+ 4 . 运行 ` goi18n merge active.*.toml translate.*.toml ` 将翻译后的消息合并到活跃消息文件
138+ (Active Message Files)中。
136139
137- ## 有关更多信息和示例 :
140+ ## 进一步的信息和示例 :
138141
139- - 阅读 [ 文档] ( https://godoc.org/github.com/nicksnyder/go-i18n/v2 ) 。
140- - 查看 [ 代码示例] ( https://github.com/nicksnyder/go-i18n/blob/main/v2/i18n/example_test.go ) 和 [ 测试] ( https://github.com/nicksnyder/go-i18n/blob/main/v2/i18n/localizer_test.go ) 。
141- - 查看一个示例 [ 程序] ( https://github.com/nicksnyder/go-i18n/tree/main/v2/example ) 。
142+ - 阅读[ 文档] ( https://pkg.go.dev/github.com/nicksnyder/go-i18n/v2 ) 。
143+ - 查看[ 代码示例] ( https://github.com/nicksnyder/go-i18n/blob/main/i18n/example_test.go ) 和
144+ [ 测试] ( https://github.com/nicksnyder/go-i18n/blob/main/i18n/localizer_test.go ) 。
145+ - 查看示例[ 程序] ( https://github.com/nicksnyder/go-i18n/tree/main/example ) 。
142146
143147## 许可证
144148
145- go-i18n 在 MIT 许可下可用。有关更多信息,请参阅 [ 许可证 ] ( LICENSE ) 文件。
149+ go-i18n 使用在 MIT 许可来提供。更多的相关信息,请参 [ LICENSE ] ( LICENSE ) 文件。
0 commit comments