diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-10-08 09:37:40 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-10-08 14:20:18 +0200 |
commit | fc6abc39c75c152780151c35bc95b12bee01b09c (patch) | |
tree | 591579c5872888acc6341aa706f8f69e8ff3837f /langs/i18n | |
parent | 18ed22be5c79a3a9bb8d3f8de30888817e751ee1 (diff) |
langs/i18n: Fix for bare TOML keys
Hugo 0.76.0 updated go-i18n from v1 to v2. This allowed us to set the TOML unmarshaler to use, so we set the one we use in other places in Hugo.
But that does not support dotted bare keys, which caused some breakage in the wild.
This commit fixes that by:
* Using go-toml for language files
* Updating go-toml to the latest version
Diffstat (limited to 'langs/i18n')
-rw-r--r-- | langs/i18n/i18n_test.go | 14 | ||||
-rw-r--r-- | langs/i18n/translationProvider.go | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/langs/i18n/i18n_test.go b/langs/i18n/i18n_test.go index 51134a7d0..baf16d4a6 100644 --- a/langs/i18n/i18n_test.go +++ b/langs/i18n/i18n_test.go @@ -199,6 +199,20 @@ other = "{{ .Count }} minuttar lesing"`), expected: "3 minuttar lesing", expectedFlag: "3 minuttar lesing", }, + // https://github.com/gohugoio/hugo/issues/7794 + { + name: "dotted-bare-key", + data: map[string][]byte{ + "en.toml": []byte(`"shop_nextPage.one" = "Show Me The Money" + +`), + }, + args: nil, + lang: "en", + id: "shop_nextPage.one", + expected: "Show Me The Money", + expectedFlag: "Show Me The Money", + }, } func doTestI18nTranslate(t testing.TB, test i18nTest, cfg config.Provider) string { diff --git a/langs/i18n/translationProvider.go b/langs/i18n/translationProvider.go index d191c0077..e478609c2 100644 --- a/langs/i18n/translationProvider.go +++ b/langs/i18n/translationProvider.go @@ -20,9 +20,9 @@ import ( "golang.org/x/text/language" yaml "gopkg.in/yaml.v2" - "github.com/BurntSushi/toml" "github.com/gohugoio/hugo/helpers" "github.com/nicksnyder/go-i18n/v2/i18n" + toml "github.com/pelletier/go-toml" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/hugofs" |