aboutsummaryrefslogtreecommitdiffhomepage
path: root/langs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-04-23 07:55:52 +0200
committerBjørn Erik Pedersen <[email protected]>2021-04-30 14:26:49 +0200
commit7eb80a9e6fcb6d31711effa20310cfefb7b23c1b (patch)
treefeff4e64e2ffd97830ba343597605c5cd63ace1b /langs
parent78c1a6a7c6e14f006854ee97ec561abdcf6203fc (diff)
downloadhugo-7eb80a9e6fcb6d31711effa20310cfefb7b23c1b.tar.gz
hugo-7eb80a9e6fcb6d31711effa20310cfefb7b23c1b.zip
langs/i18n: Fix multiple unknown language codes
This fixes a bug upstream by temporarily using a patched version of go-i18n. Closes #7838
Diffstat (limited to 'langs')
-rw-r--r--langs/i18n/i18n.go2
-rw-r--r--langs/i18n/i18n_test.go20
-rw-r--r--langs/i18n/translationProvider.go2
3 files changed, 22 insertions, 2 deletions
diff --git a/langs/i18n/i18n.go b/langs/i18n/i18n.go
index 75f0bdaaa..73e54d034 100644
--- a/langs/i18n/i18n.go
+++ b/langs/i18n/i18n.go
@@ -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
diff --git a/langs/i18n/i18n_test.go b/langs/i18n/i18n_test.go
index 278ab4446..9618d3adf 100644
--- a/langs/i18n/i18n_test.go
+++ b/langs/i18n/i18n_test.go
@@ -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",
diff --git a/langs/i18n/translationProvider.go b/langs/i18n/translationProvider.go
index e34df7e97..1151e6e1d 100644
--- a/langs/i18n/translationProvider.go
+++ b/langs/i18n/translationProvider.go
@@ -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"