diff options
author | Joe Mooring <joe.mooring@veriphor.com> | 2022-01-30 08:41:28 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-02-14 11:38:14 +0300 |
commit | 4e2b67f4e694d0248f8ff2db088856b05dea5fd7 (patch) | |
tree | 388f15daa2ed91b8f5341081b34b604fb6abba25 | |
parent | 54f7f59f39c3d6fcf8a532cc4c0f085a7aa14d61 (diff) |
Fixes gohugoio/hugo#9446
-rw-r--r-- | locales.go | 2 | ||||
-rw-r--r-- | locales_test.go | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -20,7 +20,7 @@ var ( // GetTranslator gets the Translator for the given locale, nil if not found. func GetTranslator(locale string) locales.Translator { - locale = strings.ToLower(locale) + locale = strings.ToLower(strings.ReplaceAll(locale, "-", "_")) mu.RLock() t, found := translators[locale] diff --git a/locales_test.go b/locales_test.go index 44a029f..5f20082 100644 --- a/locales_test.go +++ b/locales_test.go @@ -52,6 +52,12 @@ func TestGetTranslator(t *testing.T) { c.Assert(tnn.MonthWide(d.Month()), qt.Equals, "januar") }) + c.Run("BasicWithHyphenatedKey", func(c *qt.C) { + tnn := GetTranslator("nn-NO") + c.Assert(tnn, qt.Not(qt.IsNil)) + c.Assert(tnn.MonthWide(d.Month()), qt.Equals, "januar") + }) + // Sample tests; verify that the compression script works correctly. c.Run("Sample", func(c *qt.C) { assertSame(c, GetTranslator("en"), en.New()) |