diff options
Diffstat (limited to 'tpl/lang')
-rw-r--r-- | tpl/lang/lang_test.go | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tpl/lang/lang_test.go b/tpl/lang/lang_test.go index 3a1f66df7..8d5430f6f 100644 --- a/tpl/lang/lang_test.go +++ b/tpl/lang/lang_test.go @@ -3,9 +3,9 @@ package lang import ( "testing" - translators "github.com/gohugoio/localescompressed" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" + translators "github.com/gohugoio/localescompressed" ) func TestNumFmt(t *testing.T) { @@ -105,3 +105,36 @@ func TestFormatNumbers(t *testing.T) { }) } + +// Issue 9446 +func TestLanguageKeyFormat(t *testing.T) { + + c := qt.New(t) + + nsUnderscoreUpper := New(&deps.Deps{}, translators.GetTranslator("es_ES")) + nsUnderscoreLower := New(&deps.Deps{}, translators.GetTranslator("es_es")) + nsHyphenUpper := New(&deps.Deps{}, translators.GetTranslator("es-ES")) + nsHyphenLower := New(&deps.Deps{}, translators.GetTranslator("es-es")) + pi := 3.14159265359 + + c.Run("FormatNumber", func(c *qt.C) { + c.Parallel() + got, err := nsUnderscoreUpper.FormatNumber(3, pi) + c.Assert(err, qt.IsNil) + c.Assert(got, qt.Equals, "3,142") + + got, err = nsUnderscoreLower.FormatNumber(3, pi) + c.Assert(err, qt.IsNil) + c.Assert(got, qt.Equals, "3,142") + + got, err = nsHyphenUpper.FormatNumber(3, pi) + c.Assert(err, qt.IsNil) + c.Assert(got, qt.Equals, "3,142") + + got, err = nsHyphenLower.FormatNumber(3, pi) + c.Assert(err, qt.IsNil) + c.Assert(got, qt.Equals, "3,142") + + }) + +} |