Skip to content

Commit

Permalink
langs/i18n: Fix multiple unknown language codes
Browse files Browse the repository at this point in the history
This fixes a bug upstream by temporarily using a patched version of go-i18n.

Closes #7838
  • Loading branch information
bep committed Apr 30, 2021
1 parent 78c1a6a commit 7eb80a9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/gobuffalo/flect v0.2.2
github.com/gobwas/glob v0.2.3
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible // indirect
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95
github.com/google/go-cmp v0.5.5
github.com/gorilla/websocket v1.4.2
Expand All @@ -39,7 +41,6 @@ require (
github.com/mitchellh/mapstructure v1.3.3
github.com/muesli/smartcrop v0.3.0
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/nicksnyder/go-i18n/v2 v2.1.2
github.com/niklasfasching/go-org v1.5.0
github.com/olekukonko/tablewriter v0.0.5
github.com/pelletier/go-toml v1.9.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible h1:0d/CxRl9eRy8UOO86f80axTI2TcP1hEEgExnhFKXIkw=
github.com/gohugoio/go-i18n v2.1.3-0.20210430103248-4c28c89f8013+incompatible/go.mod h1:KyP0P5LEhJdtIq9PYxFiaxeWtFngJO5zLkDvEiqG8gI=
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013 h1:Nj29Qbkt0bZ/bJl8eccfxQp3NlU/0IW1v9eyYtQ53XQ=
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ=
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 h1:sgew0XCnZwnzpWxTt3V8LLiCO7OQi3C6dycaE67wfkU=
github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95/go.mod h1:bOlVlCa1/RajcHpXkrUXPSHB/Re1UnlXxD1Qp8SKOd8=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down
2 changes: 1 addition & 1 deletion langs/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"

"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/gohugoio/go-i18n/v2/i18n"
)

type translateFunc func(translationID string, templateData interface{}) string
Expand Down
20 changes: 20 additions & 0 deletions langs/i18n/i18n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ other = "{{ .Count }} minuttar lesing"`),
expected: "3 minuttar lesing",
expectedFlag: "3 minuttar lesing",
},
// Issue #7838
{
name: "unknown-language-codes",
data: map[string][]byte{
"en.toml": []byte(`[readingTime]
one ="en one"
other = "en count {{.Count}}"`),
"a1.toml": []byte(`[readingTime]
one = "a1 one"
other = "a1 count {{ .Count }}"`),
"a2.toml": []byte(`[readingTime]
one = "a2 one"
other = "a2 count {{ .Count }}"`),
},
args: 3,
lang: "a2",
id: "readingTime",
expected: "a2 count 3",
expectedFlag: "a2 count 3",
},
// https://github.com/gohugoio/hugo/issues/7798
{
name: "known-language-missing-plural",
Expand Down
2 changes: 1 addition & 1 deletion langs/i18n/translationProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
yaml "gopkg.in/yaml.v2"

"github.com/gohugoio/hugo/helpers"
"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/gohugoio/go-i18n/v2/i18n"
toml "github.com/pelletier/go-toml"

"github.com/gohugoio/hugo/deps"
Expand Down

0 comments on commit 7eb80a9

Please sign in to comment.