go-i18n
go-i18n copied to clipboard
Fails to resolve with multiple artificial languages
github.com/nicksnyder/go-i18n
The following test fails:
func TestPseudoLanguages(t *testing.T) {
bundle := NewBundle(language.English)
bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
expected := "a3"
bundle.MustParseMessageFileBytes([]byte(`
hello = "a1"
`), "art-x-a1.toml")
bundle.MustParseMessageFileBytes([]byte(`
hello = "a2"
`), "art-x-a2.toml")
bundle.MustParseMessageFileBytes([]byte(`
hello = "a3"
`), "art-x-a3.toml")
{
localized, err := NewLocalizer(bundle, "art-x-a3").Localize(&LocalizeConfig{MessageID: "hello"})
if err != nil {
t.Fatal(err)
}
if localized != expected {
t.Fatalf("expected %q\ngot %q", expected, localized)
}
}
}
I tried to debug this -- looks like it's some odd bug in the upstream x/text
Matcher.
https://github.com/gohugoio/hugo/issues/7838
I have a patch (almost) ready for this. Will come back with a PR.