Skip to content

Warn/Error on duplicate message Id. #332

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

Closed
zumoshi opened this issue Sep 9, 2024 · 1 comment · Fixed by #359
Closed

Warn/Error on duplicate message Id. #332

zumoshi opened this issue Sep 9, 2024 · 1 comment · Fixed by #359

Comments

@zumoshi
Copy link

zumoshi commented Sep 9, 2024

Assuming the following code:

text, err := localizer.LocalizeMessage(&i18n.Message{
	ID:          "X",
	Other:       "Text 1",
})
// ...
// somewhere else
// ...
text, err := localizer.LocalizeMessage(&i18n.Message{
	ID:          "X",
	Other:       "Something else",
})

is result of a copy paste mishap (forgot to change the message Id), the goi18n extract happily eats/ignores the first message and only outputs the second one to the translation file.

Can we get an error or warning printed out, or at the very list have the extractor create comments for filename/line numbers above the translations in the toml file so we can notice that a certain id is mentioned multiple times and investigate?

@nicksnyder
Copy link
Owner

Yeah can improve this. Will make it an extraction error if you have the same ID defined with different content.

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.

2 participants