nicksnyder / go-i18n

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

Allow MustLoadMessageFile to accept an optional langTag #347

Open jtruong2 opened 3 weeks ago

jtruong2 commented 3 weeks ago

MustLoadMessageFile() takes a path that follows the file naming convention of xxx.en.json and automatically parses the language tag. This incorrectly retrieves the language tag if the path does not follow the convention. In my case, the locales path is locales/en/translation.json. Passing this path to MustLoadMessageFile() will result in the langTag being translation instead of en. It'd be super helpful if either the function could also parse the aforementioned path or accept an optional langTag arg to override the automatic parsing.