Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/localescompressed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locales.go2
-rw-r--r--locales_test.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/locales.go b/locales.go
index c43f1be..b14a70f 100644
--- a/locales.go
+++ b/locales.go
@@ -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())