nicksnyder / go-i18n

Translate your Go program into multiple languages.
MIT License
3.03k stars 277 forks source link

Warn/Error on duplicate message Id. #332

Open zumoshi opened 2 months ago

zumoshi commented 2 months ago

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?