From dadad2bdb2a713748df0717eddd54495150cfb58 Mon Sep 17 00:00:00 2001 From: William Wilson Date: Wed, 23 Jun 2021 18:37:51 -0500 Subject: [PATCH 01/15] Update test to new error message in go 1.16 (#260) --- v2/internal/template_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/v2/internal/template_test.go b/v2/internal/template_test.go index 2f5d991b..4f569b9c 100644 --- a/v2/internal/template_test.go +++ b/v2/internal/template_test.go @@ -1,6 +1,7 @@ package internal import ( + "strings" "testing" "text/template" ) @@ -45,7 +46,7 @@ func TestExecute(t *testing.T) { template: &Template{ Src: "hello {{", }, - err: "template: :1: unexpected unclosed action in command", + err: "unclosed action", noallocs: true, }, } @@ -53,8 +54,8 @@ func TestExecute(t *testing.T) { for _, test := range tests { t.Run(test.template.Src, func(t *testing.T) { result, err := test.template.Execute(test.funcs, test.data) - if actual := str(err); actual != test.err { - t.Errorf("expected err %q; got %q", test.err, actual) + if actual := str(err); !strings.Contains(str(err), test.err) { + t.Errorf("expected err %q to contain %q", actual, test.err) } if result != test.result { t.Errorf("expected result %q; got %q", test.result, result) From 240abfe49857e6bd7b9ef60e22fc63117d2dfacc Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Wed, 23 Jun 2021 19:51:28 -0400 Subject: [PATCH 02/15] Upgrade Go to 1.16.5 (#261) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3d1e925..152714ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.15.2 + go-version: 1.16.5 - name: Git checkout uses: actions/checkout@v2 - name: Build From 7f6b563109cb7af1fc484742020b0fe7765284ee Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Sun, 20 Feb 2022 11:50:36 -0800 Subject: [PATCH 03/15] Upgrade dependencies (#268) --- .github/workflows/build.yml | 8 ++++---- .github/workflows/goreleaser.yml | 2 +- .github/workflows/lsif-go.yml | 2 ++ v2/go.mod | 6 +++--- v2/go.sum | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 152714ce..5c1ed3fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.16.5 + go-version: 1.17.7 - name: Git checkout uses: actions/checkout@v2 - name: Build @@ -25,15 +25,15 @@ jobs: run: go test -race -coverprofile=coverage.txt -covermode=atomic ./... - name: Upload coverage uses: codecov/codecov-action@v1 - build_1_9_7: - name: Build with Go 1.9.7 + build_1_12: + name: Build with Go 1.12.17 runs-on: ubuntu-latest if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request' steps: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.9.7 + go-version: 1.12.17 - name: Git checkout uses: actions/checkout@v2 with: diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index a4da7048..cbd187d5 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -18,7 +18,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: '^1.15.2' + go-version: '^1.17.7' - name: Release uses: goreleaser/goreleaser-action@v2 diff --git a/.github/workflows/lsif-go.yml b/.github/workflows/lsif-go.yml index 6ab74e00..7e56f795 100644 --- a/.github/workflows/lsif-go.yml +++ b/.github/workflows/lsif-go.yml @@ -10,5 +10,7 @@ jobs: - uses: actions/checkout@v1 - name: Generate LSIF data run: lsif-go + working-directory: v2 - name: Upload LSIF data to Sourcegraph.com run: src lsif upload -github-token=${{ secrets.GITHUB_TOKEN }} -ignore-upload-failure + working-directory: v2 diff --git a/v2/go.mod b/v2/go.mod index 447a6857..fb36943c 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,9 +1,9 @@ module github.com/nicksnyder/go-i18n/v2 -go 1.9 +go 1.12 require ( - github.com/BurntSushi/toml v0.3.1 - golang.org/x/text v0.3.3 + github.com/BurntSushi/toml v1.0.0 + golang.org/x/text v0.3.7 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/v2/go.sum b/v2/go.sum index 96bf3d75..06161a62 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,7 +1,7 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 639caa7eb5031c3fc275d5b3bf1f44fe3c3f2623 Mon Sep 17 00:00:00 2001 From: ColinBoisLydia <95220910+ColinBoisLydia@users.noreply.github.com> Date: Sat, 12 Mar 2022 22:34:15 +0100 Subject: [PATCH 04/15] doc(localizer): add specification about language tag detection (#270) --- v2/i18n/localizer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/v2/i18n/localizer.go b/v2/i18n/localizer.go index 17261e2e..256cd494 100644 --- a/v2/i18n/localizer.go +++ b/v2/i18n/localizer.go @@ -9,6 +9,15 @@ import ( ) // Localizer provides Localize and MustLocalize methods that return localized messages. +// Localize and MustLocalize methods use a language.Tag matching algorithm based +// on the best possible value. This algorithm may cause an unexpected language.Tag returned +// value depending on the order of the tags stored in memory. For example, if the bundle +// used to create a Localizer instance ingested locales following this order +// ["en-US", "en-GB", "en-IE", "en"] and the locale "en" is asked, the underlying matching +// algorithm will return "en-US" thinking it is the best match possible. More information +// about the algorithm in this Github issue: https://github.com/golang/go/issues/49176. +// There is additionnal informations inside the Go code base: +// https://github.com/golang/text/blob/master/language/match.go#L142 type Localizer struct { // bundle contains the messages that can be returned by the Localizer. bundle *Bundle From d325331ca83d2583feed708eb1f80e54ccff9133 Mon Sep 17 00:00:00 2001 From: Misite Bao Date: Thu, 30 Jun 2022 01:51:54 +0800 Subject: [PATCH 05/15] chore: add "README.zh-Hans.md" and optimized documentation (#273) --- .github/README.zh-Hans.md | 145 ++++++++++++++++++++++++++++++++++++++ README.md | 17 +++++ 2 files changed, 162 insertions(+) create mode 100644 .github/README.zh-Hans.md diff --git a/.github/README.zh-Hans.md b/.github/README.zh-Hans.md new file mode 100644 index 00000000..bd71f100 --- /dev/null +++ b/.github/README.zh-Hans.md @@ -0,0 +1,145 @@ +# 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) + +go-i18n 是一个帮助您将 Go 程序翻译成多种语言的 Go [包](#package-i18n) 和 [命令](#command-goi18n)。 + +- 支持 [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)。 + - 代码和测试是从 [CLDR 数据](http://cldr.unicode.org/index/downloads) 中 [自动生成](https://github.com/nicksnyder/go-i18n/tree/main/v2/internal/plural/codegen) 的。 +- 使用 [text/template](http://golang.org/pkg/text/template/) 语法支持带有命名变量的字符串。 +- 支持任何格式的消息文件(例如:JSON、TOML、YAML)。 + + + + +[**English**](../README.md) · [**简体中文**](README.zh-Hans.md) + + + + +## Package i18n + +[![GoDoc](https://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n) + +i18n 包支持根据一组语言环境首选项查找消息。 + +```go +import "github.com/nicksnyder/go-i18n/v2/i18n" +``` + +创建一个 Bundle 以在应用程序的整个生命周期中使用。 + +```go +bundle := i18n.NewBundle(language.English) +``` + +在初始化期间将翻译加载到您的 bundle 中。 + +```go +bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) +bundle.LoadMessageFile("es.toml") +``` + +```go +// 如果使用 go:embed +//go:embed locale.*.toml +var LocaleFS embed.FS + +bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) +bundle.LoadMessageFileFS(LocaleFS, "locale.es.toml") +``` + +创建一个 Localizer 以用于一组语言首选项。 + +```go +func(w http.ResponseWriter, r *http.Request) { + lang := r.FormValue("lang") + accept := r.Header.Get("Accept-Language") + localizer := i18n.NewLocalizer(bundle, lang, accept) +} +``` + +使用 Localizer 查找消息。 + +```go +localizer.Localize(&i18n.LocalizeConfig{ + DefaultMessage: &i18n.Message{ + ID: "PersonCats", + One: "{{.Name}} has {{.Count}} cat.", + Other: "{{.Name}} has {{.Count}} cats.", + }, + TemplateData: map[string]interface{}{ + "Name": "Nick", + "Count": 2, + }, + PluralCount: 2, +}) // Nick has 2 cats. +``` + +## goi18n 命令 + +[![GoDoc](https://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](https://godoc.org/github.com/nicksnyder/go-i18n/v2/goi18n) + +goi18n 命令管理 i18n 包使用的消息文件。 + +``` +go get -u github.com/nicksnyder/go-i18n/v2/goi18n +goi18n -help +``` + +### 提取消息 + +使用 `goi18n extract` 将 Go 源文件中的所有 i18n.Message 结构文字提取到消息文件中以进行翻译。 + +```toml +# active.en.toml +[PersonCats] +description = "The number of cats a person has" +one = "{{.Name}} has {{.Count}} cat." +other = "{{.Name}} has {{.Count}} cats." +``` + +### 翻译一种新语言 + +1. 为您要添加的语言创建一个空消息文件(例如:`translate.es.toml`)。 +2. 运行 `goi18n merge active.en.toml translate.es.toml` 以填充 `translate.es.toml` 要翻译的消息。 + + ```toml + # translate.es.toml + [HelloPerson] + hash = "sha1-5b49bfdad81fedaeefb224b0ffc2acc58b09cff5" + other = "Hello {{.Name}}" + ``` + +3. 翻译完成 `translate.es.toml` 后,将其重命名为 `active.es.toml``。 + + ```toml + # active.es.toml + [HelloPerson] + hash = "sha1-5b49bfdad81fedaeefb224b0ffc2acc58b09cff5" + other = "Hola {{.Name}}" + ``` + +4. 加载 `active.es.toml` 到您的 bundle 中。 + + ```go + bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) + bundle.LoadMessageFile("active.es.toml") + ``` + +### 翻译新消息 + +如果您在程序中添加了新消息: + +1. 运行 `goi18n extract` 以使用新消息更新 `active.en.toml`。 +2. 运行 `goi18n merge active.*.toml` 以生成更新的 `translate.*.toml` 文件。 +3. 翻译 `translate.*.toml` 文件中的所有消息。 +4. 运行 `goi18n merge active.*.toml translate.*.toml` 将翻译后的消息合并到 active 消息文件中。 + +## 有关更多信息和示例: + +- 阅读 [文档](https://godoc.org/github.com/nicksnyder/go-i18n/v2)。 +- 查看 [代码示例](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)。 +- 查看一个示例 [程序](https://github.com/nicksnyder/go-i18n/tree/main/v2/example)。 + +## 许可证 + +go-i18n 在 MIT 许可下可用。有关更多信息,请参阅 [许可证](LICENSE) 文件。 diff --git a/README.md b/README.md index a13f268b..4136baed 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,14 @@ go-i18n is a Go [package](#package-i18n) and a [command](#command-goi18n) that h - Supports strings with named variables using [text/template](http://golang.org/pkg/text/template/) syntax. - Supports message files of any format (e.g. JSON, TOML, YAML). + + + +[**English**](README.md) · [**简体中文**](.github/README.zh-Hans.md) + + + + ## Package i18n [![GoDoc](https://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n) @@ -29,6 +37,15 @@ bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) bundle.LoadMessageFile("es.toml") ``` +```go +// If use go:embed +//go:embed locale.*.toml +var LocaleFS embed.FS + +bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) +bundle.LoadMessageFileFS(LocaleFS, "locale.es.toml") +``` + Create a Localizer to use for a set of language preferences. ```go From 57bd175f4eca85b370ebc664ec389a6c40d89d81 Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Wed, 29 Jun 2022 13:52:30 -0400 Subject: [PATCH 06/15] go 1.18.3 (#274) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c1ed3fd..03f28bd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.17.7 + go-version: 1.18.3 - name: Git checkout uses: actions/checkout@v2 - name: Build From 4c50337b6d89a5f97b576ee35489998ec54b7b2b Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Tue, 1 Nov 2022 16:49:59 -0700 Subject: [PATCH 07/15] Update to golang.org/x/text v0.4.0 (#286) --- v2/go.mod | 2 +- v2/go.sum | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/v2/go.mod b/v2/go.mod index fb36943c..2d607b15 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -4,6 +4,6 @@ go 1.12 require ( github.com/BurntSushi/toml v1.0.0 - golang.org/x/text v0.3.7 + golang.org/x/text v0.4.0 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/v2/go.sum b/v2/go.sum index 06161a62..5674dfff 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,8 +1,31 @@ github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= From 85a3f2b18e445306e0a1b6076d4f2a48ae32f066 Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Thu, 10 Nov 2022 08:23:54 -0800 Subject: [PATCH 08/15] Upgrade to Go 1.19.3 (#288) --- .github/workflows/build.yml | 2 +- .github/workflows/goreleaser.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03f28bd7..e505baf4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.18.3 + go-version: 1.19.3 - name: Git checkout uses: actions/checkout@v2 - name: Build diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index cbd187d5..3148e4d8 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -18,7 +18,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: '^1.17.7' + go-version: '^1.19.3' - name: Release uses: goreleaser/goreleaser-action@v2 From 6bb0339bba40dcdda3a822dbe38cf4bd8c0f680c Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Mon, 5 Dec 2022 20:10:22 -0800 Subject: [PATCH 09/15] Update install instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4136baed..c703817a 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ localizer.Localize(&i18n.LocalizeConfig{ The goi18n command manages message files used by the i18n package. ``` -go get -u github.com/nicksnyder/go-i18n/v2/goi18n +go install -v github.com/nicksnyder/go-i18n/v2/goi18n@latest goi18n -help ``` From 57ba61f1e59e47c0dff18ae9f7e5b36988a1de94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20=C3=96zceviz?= Date: Tue, 9 May 2023 22:25:52 +0200 Subject: [PATCH 10/15] fix comment on MustLoadMessageFile function (#298) --- v2/i18n/bundle.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/i18n/bundle.go b/v2/i18n/bundle.go index 513c127d..21651f31 100644 --- a/v2/i18n/bundle.go +++ b/v2/i18n/bundle.go @@ -59,7 +59,7 @@ func (b *Bundle) LoadMessageFile(path string) (*MessageFile, error) { return b.ParseMessageFileBytes(buf, path) } -// MustLoadMessageFile is similar to LoadTranslationFile +// MustLoadMessageFile is similar to LoadMessageFile // except it panics if an error happens. func (b *Bundle) MustLoadMessageFile(path string) { if _, err := b.LoadMessageFile(path); err != nil { From 719fa821c00ac29ea95d30bbad397335ddd300d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=8C=E8=80=85?= <1243463730@qq.com> Date: Sat, 10 Jun 2023 11:11:49 +0800 Subject: [PATCH 11/15] =?UTF-8?q?goi18n=E5=AE=89=E8=A3=85=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E6=9B=B4=E6=96=B0=20(#296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit goi18n安装命令更新 --- .github/README.zh-Hans.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.zh-Hans.md b/.github/README.zh-Hans.md index bd71f100..c80966a6 100644 --- a/.github/README.zh-Hans.md +++ b/.github/README.zh-Hans.md @@ -81,7 +81,7 @@ localizer.Localize(&i18n.LocalizeConfig{ goi18n 命令管理 i18n 包使用的消息文件。 ``` -go get -u github.com/nicksnyder/go-i18n/v2/goi18n +go install -v github.com/nicksnyder/go-i18n/v2/goi18n@latest goi18n -help ``` From cdca9f2e7aba75b3d90375cf331e9dacef57ea60 Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Fri, 9 Jun 2023 20:46:59 -0700 Subject: [PATCH 12/15] Fix build (#299) --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e505baf4..68b3c3d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: 1.12.17 + go-version: '1.12.17' - name: Git checkout uses: actions/checkout@v2 with: @@ -42,6 +42,7 @@ jobs: working-directory: gopath/src/github.com/nicksnyder/go-i18n/v2 env: GOPATH: ${{ github.workspace }}/gopath + GO111MODULE: on run: | - go get -t ./... + go get ./... go test -race ./... From 381afe6807f01999bbbcfbc24d67d2bb61221bd9 Mon Sep 17 00:00:00 2001 From: Nick Snyder Date: Fri, 9 Jun 2023 20:54:56 -0700 Subject: [PATCH 13/15] Update GitHub actions (#300) --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68b3c3d9..735e02d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,11 +9,11 @@ jobs: if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request' steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: 1.19.3 + go-version: stable - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build uses: goreleaser/goreleaser-action@v2 with: @@ -31,11 +31,11 @@ jobs: if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'pull_request' steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: '1.12.17' - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: gopath/src/github.com/nicksnyder/go-i18n - name: Build and test From e3e883d49ae440f38e9ef8dfdbf956f6c212e6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 23 Apr 2021 08:37:22 +0200 Subject: [PATCH 14/15] Fix handling of multiple artificial languages This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages. Fixes #252 --- v2/i18n/bundle.go | 53 ++++++++++++++++++++++++++++++++++++++++-- v2/i18n/bundle_test.go | 25 ++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/v2/i18n/bundle.go b/v2/i18n/bundle.go index 21651f31..a30af3c2 100644 --- a/v2/i18n/bundle.go +++ b/v2/i18n/bundle.go @@ -26,9 +26,58 @@ type Bundle struct { matcher language.Matcher } +// The matcher in x/text/language does not handle artificial languages, +// see https://github.com/golang/go/issues/45749 +// This is a simplified matcher that delegates to the x/text/language matcher for +// the harder cases. +type matcher struct { + tags []language.Tag + defaultMatcher language.Matcher +} + +func newMatcher(tags []language.Tag) language.Matcher { + var hasArt bool + for _, tag := range tags { + base, _ := tag.Base() + hasArt = base == artTagBase + if hasArt { + break + } + } + + if !hasArt { + return language.NewMatcher(tags) + } + + return matcher{ + tags: tags, + defaultMatcher: language.NewMatcher(tags), + } +} + +func (m matcher) Match(t ...language.Tag) (language.Tag, int, language.Confidence) { + for _, candidate := range t { + base, _ := candidate.Base() + if base != artTagBase { + continue + } + + for i, tag := range m.tags { + if tag == candidate { + return candidate, i, language.Exact + } + } + } + + return m.defaultMatcher.Match(t...) +} + // artTag is the language tag used for artificial languages // https://en.wikipedia.org/wiki/Codes_for_constructed_languages -var artTag = language.MustParse("art") +var ( + artTag = language.MustParse("art") + artTagBase, _ = artTag.Base() +) // NewBundle returns a bundle with a default language and a default set of plural rules. func NewBundle(defaultLanguage language.Tag) *Bundle { @@ -126,7 +175,7 @@ func (b *Bundle) addTag(tag language.Tag) { } } b.tags = append(b.tags, tag) - b.matcher = language.NewMatcher(b.tags) + b.matcher = newMatcher(b.tags) } // LanguageTags returns the list of language tags diff --git a/v2/i18n/bundle_test.go b/v2/i18n/bundle_test.go index 12377899..e4f9280c 100644 --- a/v2/i18n/bundle_test.go +++ b/v2/i18n/bundle_test.go @@ -98,6 +98,31 @@ hello = "`+expected+`" } } +func TestPseudoLanguages(t *testing.T) { + bundle := NewBundle(language.English) + bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) + expected := "a2" + bundle.MustParseMessageFileBytes([]byte(` +hello = "a1" +`), "art-x-a1.toml") + bundle.MustParseMessageFileBytes([]byte(` +hello = "a2" +`), "art-x-a2.toml") + bundle.MustParseMessageFileBytes([]byte(` +hello = "a3" +`), "art-x-a3.toml") + + { + localized, err := NewLocalizer(bundle, "art-x-a2").Localize(&LocalizeConfig{MessageID: "hello"}) + if err != nil { + t.Fatal(err) + } + if localized != expected { + t.Fatalf("expected %q\ngot %q", expected, localized) + } + } +} + func TestJSON(t *testing.T) { bundle := NewBundle(language.English) bundle.MustParseMessageFileBytes([]byte(`{ From 9d0cd88c651386279e47d5b790276099c6266522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 30 Apr 2021 12:32:48 +0200 Subject: [PATCH 15/15] Temporary update module path --- v2/example/main.go | 2 +- v2/go.mod | 8 ++++---- v2/go.sum | 29 +++-------------------------- v2/goi18n/extract_command.go | 4 ++-- v2/goi18n/extract_command_test.go | 24 ++++++++++++------------ v2/goi18n/main.go | 2 +- v2/goi18n/marshal.go | 4 ++-- v2/goi18n/merge_command.go | 6 +++--- v2/i18n/bundle.go | 2 +- v2/i18n/example_test.go | 2 +- v2/i18n/localizer.go | 2 +- v2/i18n/localizer_test.go | 2 +- v2/i18n/message_template.go | 4 ++-- v2/i18n/message_template_test.go | 2 +- 14 files changed, 35 insertions(+), 58 deletions(-) diff --git a/v2/example/main.go b/v2/example/main.go index 838e1456..cc656340 100644 --- a/v2/example/main.go +++ b/v2/example/main.go @@ -9,7 +9,7 @@ import ( "strconv" "github.com/BurntSushi/toml" - "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/gohugoio/go-i18n/v2/i18n" "golang.org/x/text/language" ) diff --git a/v2/go.mod b/v2/go.mod index 2d607b15..b11a0ed9 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,9 +1,9 @@ -module github.com/nicksnyder/go-i18n/v2 +module github.com/gohugoio/go-i18n/v2 -go 1.12 +go 1.16 require ( - github.com/BurntSushi/toml v1.0.0 - golang.org/x/text v0.4.0 + github.com/BurntSushi/toml v0.3.1 + golang.org/x/text v0.3.3 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/v2/go.sum b/v2/go.sum index 5674dfff..96bf3d75 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -1,31 +1,8 @@ -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= diff --git a/v2/goi18n/extract_command.go b/v2/goi18n/extract_command.go index 67afab4a..2fbc7c04 100644 --- a/v2/goi18n/extract_command.go +++ b/v2/goi18n/extract_command.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/gohugoio/go-i18n/v2/i18n" ) func usageExtract() { @@ -282,7 +282,7 @@ func extractStringLiteral(expr ast.Expr) (string, bool) { func i18nPackageName(file *ast.File) string { for _, i := range file.Imports { - if i.Path.Kind == token.STRING && i.Path.Value == `"github.com/nicksnyder/go-i18n/v2/i18n"` { + if i.Path.Kind == token.STRING && i.Path.Value == `"github.com/gohugoio/go-i18n/v2/i18n"` { if i.Name == nil { return "i18n" } diff --git a/v2/goi18n/extract_command_test.go b/v2/goi18n/extract_command_test.go index 3cfe581b..60af3a8f 100644 --- a/v2/goi18n/extract_command_test.go +++ b/v2/goi18n/extract_command_test.go @@ -26,7 +26,7 @@ func TestExtract(t *testing.T) { fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var m = &i18n.Message{ ID: "Plural ID", @@ -38,7 +38,7 @@ func TestExtract(t *testing.T) { fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var hasnewline = &i18n.Message{ ID: "hasnewline", @@ -53,7 +53,7 @@ func TestExtract(t *testing.T) { fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var a = &i18n.Message{ ID: "a", @@ -73,7 +73,7 @@ b = "a \" b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var a = []*i18n.Message{ { @@ -95,7 +95,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var a = map[string]*i18n.Message{ "a": { @@ -117,7 +117,7 @@ b = "b" fileName: "file_test.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" func main() { bundle := i18n.NewBundle(language.English) @@ -131,7 +131,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" func main() { bundle := i18n.NewBundle(language.English) @@ -145,7 +145,7 @@ b = "b" fileName: "file.go", file: `package main - import bar "github.com/nicksnyder/go-i18n/v2/i18n" + import bar "github.com/gohugoio/go-i18n/v2/i18n" func main() { _ := &bar.Message{ @@ -159,7 +159,7 @@ b = "b" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" func main() { _ := &i18n.Message{ @@ -189,7 +189,7 @@ zero = "Zero translation" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" func main() { _ := &i18n.Message{ @@ -205,7 +205,7 @@ zero = "Zero translation" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" const constID = "ConstantID" @@ -222,7 +222,7 @@ zero = "Zero translation" fileName: "file.go", file: `package main - import "github.com/nicksnyder/go-i18n/v2/i18n" + import "github.com/gohugoio/go-i18n/v2/i18n" var m = &i18n.LocalizeConfig{ Funcs: Funcs, diff --git a/v2/goi18n/main.go b/v2/goi18n/main.go index f2f3d2c1..bc8668e4 100644 --- a/v2/goi18n/main.go +++ b/v2/goi18n/main.go @@ -1,6 +1,6 @@ // Command goi18n manages message files used by the i18n package. // -// go get -u github.com/nicksnyder/go-i18n/v2/goi18n +// go get -u github.com/gohugoio/go-i18n/v2/goi18n // goi18n -help // // Use `goi18n extract` to create a message file that contains the messages defined in your Go source files. diff --git a/v2/goi18n/marshal.go b/v2/goi18n/marshal.go index a6cc762f..396947a3 100644 --- a/v2/goi18n/marshal.go +++ b/v2/goi18n/marshal.go @@ -7,8 +7,8 @@ import ( "path/filepath" "github.com/BurntSushi/toml" - "github.com/nicksnyder/go-i18n/v2/i18n" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/i18n" + "github.com/gohugoio/go-i18n/v2/internal/plural" "golang.org/x/text/language" yaml "gopkg.in/yaml.v2" ) diff --git a/v2/goi18n/merge_command.go b/v2/goi18n/merge_command.go index b736dfe9..26909d15 100644 --- a/v2/goi18n/merge_command.go +++ b/v2/goi18n/merge_command.go @@ -10,9 +10,9 @@ import ( "os" "github.com/BurntSushi/toml" - "github.com/nicksnyder/go-i18n/v2/i18n" - "github.com/nicksnyder/go-i18n/v2/internal" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/i18n" + "github.com/gohugoio/go-i18n/v2/internal" + "github.com/gohugoio/go-i18n/v2/internal/plural" "golang.org/x/text/language" yaml "gopkg.in/yaml.v2" ) diff --git a/v2/i18n/bundle.go b/v2/i18n/bundle.go index a30af3c2..308430fa 100644 --- a/v2/i18n/bundle.go +++ b/v2/i18n/bundle.go @@ -4,7 +4,7 @@ import ( "fmt" "io/ioutil" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/example_test.go b/v2/i18n/example_test.go index 2256e636..4942df57 100644 --- a/v2/i18n/example_test.go +++ b/v2/i18n/example_test.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/BurntSushi/toml" - "github.com/nicksnyder/go-i18n/v2/i18n" + "github.com/gohugoio/go-i18n/v2/i18n" "golang.org/x/text/language" ) diff --git a/v2/i18n/localizer.go b/v2/i18n/localizer.go index 256cd494..4415c7d7 100644 --- a/v2/i18n/localizer.go +++ b/v2/i18n/localizer.go @@ -4,7 +4,7 @@ import ( "fmt" "text/template" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/localizer_test.go b/v2/i18n/localizer_test.go index 3dedfb67..12d646d3 100644 --- a/v2/i18n/localizer_test.go +++ b/v2/i18n/localizer_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/internal/plural" "golang.org/x/text/language" ) diff --git a/v2/i18n/message_template.go b/v2/i18n/message_template.go index a1a619e2..eae3cc7a 100644 --- a/v2/i18n/message_template.go +++ b/v2/i18n/message_template.go @@ -5,8 +5,8 @@ import ( "text/template" - "github.com/nicksnyder/go-i18n/v2/internal" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/internal" + "github.com/gohugoio/go-i18n/v2/internal/plural" ) // MessageTemplate is an executable template for a message. diff --git a/v2/i18n/message_template_test.go b/v2/i18n/message_template_test.go index d920cd4d..6eae20ad 100644 --- a/v2/i18n/message_template_test.go +++ b/v2/i18n/message_template_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/nicksnyder/go-i18n/v2/internal/plural" + "github.com/gohugoio/go-i18n/v2/internal/plural" ) func TestMessageTemplate(t *testing.T) {