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

The Option in TextParser is not used #334

Closed
cazeaux opened this issue Oct 8, 2024 · 0 comments · Fixed by #335
Closed

The Option in TextParser is not used #334

cazeaux opened this issue Oct 8, 2024 · 0 comments · Fixed by #335

Comments

@cazeaux
Copy link
Contributor

cazeaux commented Oct 8, 2024

If we define a custom TemplateParser with some Option, the option has no effect.

Example:

bundle := NewBundle(language.English)
bundle.AddMessages(language.English, {ID: "Foo", Other: "Foo {{.bar}}!"}...)
conf := &LocalizeConfig{
  MessageID:      "Foo",
  TemplateData:   map[string]string{}, // empty data
  TemplateParser: &template.TextParser{Option: "missingkey=error"}, // I want an error if `bar` is not in data
}
localizer := NewLocalizer(bundle, []string{"en"})
s, err := localizer.Localize(conf)) // I expect an error here

This is because the .Option() is not used in TextParser.

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