Approach to internationalization. How is go-i18n integrated into WeGO?
Edit me
The WEGO Internationalization Framework
WeGO integrates with go-i18n from Nick Snyder. There are conventions around the usage of this package in a WeGO application.
It is assumed that ${CONFIGPATH}/bundles will have all the i18n files in toml format (the only supported format for now). These files are automatically initialized when WeGO library is initialized. The i18n package within WeGO exposes the following function
Translate(ctx context.Context, s string, m map[string]interface{}) string
This function accepts a resource bundle key - s and translates it to the language specified using the following cascading mechanism :
- If a “lang” header is found in the context then that is given the highest preference.
- If an “Accept-Language” header is found in the context it is given the next preference
- Finally, the default language is chosen if none of the two above are present.
If the key is missing then a default message is printed with the entire contents of the map.