nicksnyder / go-i18n

Translate your Go program into multiple languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please explain how the user's current language is selected at runtime

plastikfan opened this issue · comments

I have been trying to understand how go-i18n selects the end user's language at runtime, but so far not found how this works.. I can see the Localizer struct has an internal tags member, and the bundle is created with a set of supported languages, but how is the end users language actually detected and set at runtime. I have looked at all the documentation/examples and perused the source code but can't see how this works.

Please can you let me know how this works or document it somewhere. There is another go package jibberjabber that performs this function, but there is nothing equaivalent to this in go-i18n.

This knowledge is also required for testing purposes. How do I test a supported language that is not the default? If the client doesn't explicitly set the current language, then how can a unit test be written to test an alternative dialect?

Thanks.