Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to resolve with multiple artificial languages #252

Open
bep opened this issue Apr 23, 2021 · 1 comment · May be fixed by #253
Open

Fails to resolve with multiple artificial languages #252

bep opened this issue Apr 23, 2021 · 1 comment · May be fixed by #253

Comments

@bep
Copy link
Contributor

bep commented Apr 23, 2021

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.

gohugoio/hugo#7838

bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
@bep
Copy link
Contributor Author

bep commented Apr 24, 2021

I have a patch (almost) ready for this. Will come back with a PR.

bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to bep/go-i18n that referenced this issue Apr 24, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
@bep bep linked a pull request Apr 24, 2021 that will close this issue
bep added a commit to bep/go-i18n that referenced this issue Apr 25, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to bep/go-i18n that referenced this issue Apr 26, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to gohugoio/go-i18n that referenced this issue Apr 30, 2021
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
bep added a commit to gohugoio/go-i18n that referenced this issue Aug 5, 2023
This works around what seems to be an upstream by implementing a simplified tag matcher for artificual languages.

Fixes nicksnyder#252
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant