New Upstream Snapshot - golang-github-nicksnyder-go-i18n.v2

Ready changes

Summary

Merged new upstream version: 2.2.1+git20221205.1.6bb0339 (was: 2.2.0+git20220312.1.639caa7).

Resulting package

Built on 2022-12-16T16:45 (took 20m36s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-nicksnyder-go-i18n.v2-dev

Lintian Result

Diff

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 55d9460..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: Build
-on:
-  - push
-  - pull_request
-jobs:
-  build:
-    name: Build
-    runs-on: ubuntu-latest
-    if: (github.event_name == 'push' && github.repository_owner == 'nicksnyder') || (github.event_name == 'pull_request' && github.repository_owner != 'nicksnyder')
-    steps:
-      - name: Install Go
-        uses: actions/setup-go@v2
-        with:
-          go-version: 1.15.2
-      - name: Git checkout
-        uses: actions/checkout@v2
-      - name: Build
-        uses: goreleaser/goreleaser-action@v2
-        with:
-          version: latest
-          args: release --rm-dist --snapshot
-          workdir: v2
-      - name: Test
-        working-directory: v2
-        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
-    runs-on: ubuntu-latest
-    if: (github.event_name == 'push' && github.repository_owner == 'nicksnyder') || (github.event_name == 'pull_request' && github.repository_owner != 'nicksnyder')
-    steps:
-      - name: Install Go
-        uses: actions/setup-go@v2
-        with:
-          go-version: 1.9.7
-      - name: Git checkout
-        uses: actions/checkout@v2
-        with:
-          path: gopath/src/github.com/nicksnyder/go-i18n
-      - name: Build and test
-        working-directory: gopath/src/github.com/nicksnyder/go-i18n/v2
-        env:
-            GOPATH: ${{ github.workspace }}/gopath
-        run: |
-          go get -t ./...
-          go test -race ./...
diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml
deleted file mode 100644
index a4da704..0000000
--- a/.github/workflows/goreleaser.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-name: goreleaser
-
-on:
-  push:
-    tags:
-      - '*'
-
-jobs:
-  goreleaser:
-    runs-on: ubuntu-latest
-    steps:
-      -
-        name: Checkout
-        uses: actions/checkout@v2
-        with:
-          fetch-depth: 0
-      -
-        name: Set up Go
-        uses: actions/setup-go@v2
-        with:
-          go-version: '^1.15.2'
-      -
-        name: Release
-        uses: goreleaser/goreleaser-action@v2
-        with:
-          version: latest
-          args: release --rm-dist
-          workdir: v2
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          
diff --git a/.github/workflows/lsif-go.yml b/.github/workflows/lsif-go.yml
deleted file mode 100644
index 6ab74e0..0000000
--- a/.github/workflows/lsif-go.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-name: Sourcegraph code intelligence
-on:
-  - push
-
-jobs:
-  lsif-go:
-    runs-on: ubuntu-latest
-    container: sourcegraph/lsif-go:latest
-    steps:
-      - uses: actions/checkout@v1
-      - name: Generate LSIF data
-        run: lsif-go
-      - name: Upload LSIF data to Sourcegraph.com
-        run: src lsif upload -github-token=${{ secrets.GITHUB_TOKEN }} -ignore-upload-failure
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 6685f2d..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-*.a
-_*
-output/
-.DS_Store
-*.test
-*.swp
-
-v2/example/example
-v2/goi18n/goi18n
-v2/dist/
-v2/coverage.txt
diff --git a/README.md b/README.md
index d292ea3..c703817 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,21 @@
 
 go-i18n is a Go [package](#package-i18n) and a [command](#command-goi18n) that helps you translate Go programs into multiple languages.
 
-- Supports [pluralized strings](http://cldr.unicode.org/index/cldr-spec/plural-rules) for all 200+ languages in the [Unicode Common Locale Data Repository (CLDR)](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html).
-  - Code and tests are [automatically generated](https://github.com/nicksnyder/go-i18n/tree/master/i18n/language/codegen) from [CLDR data](http://cldr.unicode.org/index/downloads).
+- Supports [pluralized strings](http://cldr.unicode.org/index/cldr-spec/plural-rules) for all 200+ languages in the [Unicode Common Locale Data Repository (CLDR)](https://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html).
+  - Code and tests are [automatically generated](https://github.com/nicksnyder/go-i18n/tree/main/v2/internal/plural/codegen) from [CLDR data](http://cldr.unicode.org/index/downloads).
 - 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).
 
-## Package i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n)
+<strong align="center">
+<samp>
+
+[**English**](README.md) · [**简体中文**](.github/README.zh-Hans.md)
+
+</samp>
+</strong>
+
+## Package i18n
+[![GoDoc](https://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](https://godoc.org/github.com/nicksnyder/go-i18n/v2/i18n)
 
 The i18n package provides support for looking up messages according to a set of locale preferences.
 
@@ -28,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
@@ -55,12 +73,13 @@ localizer.Localize(&i18n.LocalizeConfig{
 }) // Nick has 2 cats.
 ```
 
-## Command goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](http://godoc.org/github.com/nicksnyder/go-i18n/v2/goi18n)
+## Command goi18n
+[![GoDoc](https://godoc.org/github.com/nicksnyder/go-i18n?status.svg)](https://godoc.org/github.com/nicksnyder/go-i18n/v2/goi18n)
 
 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
 ```
 
@@ -115,9 +134,9 @@ If you have added new messages to your program:
 
 ## For more information and examples:
 
-- Read the [documentation](http://godoc.org/github.com/nicksnyder/go-i18n/v2).
-- Look at the [code examples](https://github.com/nicksnyder/go-i18n/blob/master/v2/i18n/example_test.go) and [tests](https://github.com/nicksnyder/go-i18n/blob/master/v2/i18n/localizer_test.go).
-- Look at an example [application](https://github.com/nicksnyder/go-i18n/tree/master/v2/example).
+- Read the [documentation](https://godoc.org/github.com/nicksnyder/go-i18n/v2).
+- Look at the [code examples](https://github.com/nicksnyder/go-i18n/blob/main/v2/i18n/example_test.go) and [tests](https://github.com/nicksnyder/go-i18n/blob/main/v2/i18n/localizer_test.go).
+- Look at an example [application](https://github.com/nicksnyder/go-i18n/tree/main/v2/example).
 
 ## License
 
diff --git a/debian/changelog b/debian/changelog
index dff649d..7cddb14 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+golang-github-nicksnyder-go-i18n.v2 (2.2.1+git20221205.1.6bb0339-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+  * Drop patch 0001-Update-test-to-new-error-message-in-go-1.16-260.patch,
+    present upstream.
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 16 Dec 2022 16:33:01 -0000
+
 golang-github-nicksnyder-go-i18n.v2 (2.1.2-1) unstable; urgency=medium
 
   * New upstream version 2.1.2
diff --git a/debian/patches/0001-Update-test-to-new-error-message-in-go-1.16-260.patch b/debian/patches/0001-Update-test-to-new-error-message-in-go-1.16-260.patch
deleted file mode 100644
index dd36e3a..0000000
--- a/debian/patches/0001-Update-test-to-new-error-message-in-go-1.16-260.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From dadad2bdb2a713748df0717eddd54495150cfb58 Mon Sep 17 00:00:00 2001
-From: William Wilson <william.wilson@canonical.com>
-Date: Wed, 23 Jun 2021 18:37:51 -0500
-Subject: [PATCH] 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 2f5d991..4f569b9 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)
--- 
-2.34.0
-
diff --git a/debian/patches/series b/debian/patches/series
index 736f6e2..e69de29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +0,0 @@
-0001-Update-test-to-new-error-message-in-go-1.16-260.patch
diff --git a/v2/go.mod b/v2/go.mod
index 447a685..2d607b1 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.4.0
 	gopkg.in/yaml.v2 v2.3.0
 )
diff --git a/v2/go.sum b/v2/go.sum
index 96bf3d7..5674dff 100644
--- a/v2/go.sum
+++ b/v2/go.sum
@@ -1,8 +1,31 @@
-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=
+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=
diff --git a/v2/i18n/bundlefs.go b/v2/i18n/bundlefs.go
new file mode 100644
index 0000000..50c794b
--- /dev/null
+++ b/v2/i18n/bundlefs.go
@@ -0,0 +1,18 @@
+// +build go1.16
+
+package i18n
+
+import (
+	"io/fs"
+)
+
+// LoadMessageFileFS is like LoadMessageFile but instead of reading from the
+// hosts operating system's file system it reads from the fs file system.
+func (b *Bundle) LoadMessageFileFS(fsys fs.FS, path string) (*MessageFile, error) {
+	buf, err := fs.ReadFile(fsys, path)
+	if err != nil {
+		return nil, err
+	}
+
+	return b.ParseMessageFileBytes(buf, path)
+}
diff --git a/v2/i18n/localizer.go b/v2/i18n/localizer.go
index 17261e2..256cd49 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
diff --git a/v2/internal/plural/codegen/README.md b/v2/internal/plural/codegen/README.md
index 41a0094..f1f5ff8 100644
--- a/v2/internal/plural/codegen/README.md
+++ b/v2/internal/plural/codegen/README.md
@@ -1,6 +1,6 @@
 # How to upgrade CLDR data
 
 1.  Go to http://cldr.unicode.org/index/downloads to find the latest version.
-1.  Download the latest version of cldr-common (e.g. http://unicode.org/Public/cldr/37/cldr-common-37.0.zip)
+1.  Download the latest version of cldr-common (e.g. https://unicode.org/Public/cldr/39/cldr-common-39.0.zip)
 1.  Unzip and copy `common/supplemental/plurals.xml` to this directory.
 1.  Run `generate.sh`.
diff --git a/v2/internal/template_test.go b/v2/internal/template_test.go
index 2f5d991..4f569b9 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)

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/gocode/src/github.com/nicksnyder/go-i18n/v2/i18n/bundlefs.go

No differences were encountered in the control files

More details

Full run details