langs/i18n: Fix multiple unknown language codes

This fixes a bug upstream by temporarily using a patched version of go-i18n.

Closes #7838
This commit is contained in:
Bjørn Erik Pedersen
2021-04-23 07:55:52 +02:00
parent 78c1a6a7c6
commit 7eb80a9e6f
5 changed files with 28 additions and 3 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -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"