Skip to content

Commit 7eb80a9

Browse files
committed
langs/i18n: Fix multiple unknown language codes
This fixes a bug upstream by temporarily using a patched version of go-i18n. Closes #7838
1 parent 78c1a6a commit 7eb80a9

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

‎go.mod‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ require (
2626
github.com/ghodss/yaml v1.0.0
2727
github.com/gobuffalo/flect v0.2.2
2828
github.com/gobwas/glob v0.2.3
29+
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible // indirect
30+
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013
2931
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95
3032
github.com/google/go-cmp v0.5.5
3133
github.com/gorilla/websocket v1.4.2
@@ -39,7 +41,6 @@ require (
3941
github.com/mitchellh/mapstructure v1.3.3
4042
github.com/muesli/smartcrop v0.3.0
4143
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
42-
github.com/nicksnyder/go-i18n/v2 v2.1.2
4344
github.com/niklasfasching/go-org v1.5.0
4445
github.com/olekukonko/tablewriter v0.0.5
4546
github.com/pelletier/go-toml v1.9.0

‎go.sum‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
227227
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
228228
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
229229
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
230+
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible h1:0d/CxRl9eRy8UOO86f80axTI2TcP1hEEgExnhFKXIkw=
231+
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible/go.mod h1:KyP0P5LEhJdtIq9PYxFiaxeWtFngJO5zLkDvEiqG8gI=
232+
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013 h1:Nj29Qbkt0bZ/bJl8eccfxQp3NlU/0IW1v9eyYtQ53XQ=
233+
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ=
230234
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 h1:sgew0XCnZwnzpWxTt3V8LLiCO7OQi3C6dycaE67wfkU=
231235
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95/go.mod h1:bOlVlCa1/RajcHpXkrUXPSHB/Re1UnlXxD1Qp8SKOd8=
232236
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=

‎langs/i18n/i18n.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/gohugoio/hugo/config"
2525
"github.com/gohugoio/hugo/helpers"
2626

27-
"github.com/nicksnyder/go-i18n/v2/i18n"
27+
"github.com/gohugoio/go-i18n/v2/i18n"
2828
)
2929

3030
type translateFunc func(translationID string, templateData interface{}) string

‎langs/i18n/i18n_test.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@ other = "{{ .Count }} minuttar lesing"`),
271271
expected: "3 minuttar lesing",
272272
expectedFlag: "3 minuttar lesing",
273273
},
274+
// Issue #7838
275+
{
276+
name: "unknown-language-codes",
277+
data: map[string][]byte{
278+
"en.toml": []byte(`[readingTime]
279+
one ="en one"
280+
other = "en count {{.Count}}"`),
281+
"a1.toml": []byte(`[readingTime]
282+
one = "a1 one"
283+
other = "a1 count {{ .Count }}"`),
284+
"a2.toml": []byte(`[readingTime]
285+
one = "a2 one"
286+
other = "a2 count {{ .Count }}"`),
287+
},
288+
args: 3,
289+
lang: "a2",
290+
id: "readingTime",
291+
expected: "a2 count 3",
292+
expectedFlag: "a2 count 3",
293+
},
274294
// https://github.com/gohugoio/hugo/issues/7798
275295
{
276296
name: "known-language-missing-plural",

‎langs/i18n/translationProvider.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
yaml "gopkg.in/yaml.v2"
2323

2424
"github.com/gohugoio/hugo/helpers"
25-
"github.com/nicksnyder/go-i18n/v2/i18n"
25+
"github.com/gohugoio/go-i18n/v2/i18n"
2626
toml "github.com/pelletier/go-toml"
2727

2828
"github.com/gohugoio/hugo/deps"

0 commit comments

Comments
 (0)