This way Lingo will return the bundle for specific locale, or default if given is not found.
Alternatively (or primarily), you can get it with *http.Request:
t := l.TranslationsForRequest(req)
This way Lingo finds best suited locale via Accept-Language header, or if there is no match, returns default.
Accept-Language header is set by the browser, so basically it will serve the language the user has set to his browser.
Once you get T instance just fire away!
r1 := t1.Value("main.subtitle")
// "Knives that put cut in cutlery."
r1 := t2.Value("main.subtitle")
// "Messer, die legte in Besteck geschnitten."
r3 := t1.Value("menu.products.self")
// "Products"
r5 := t1.Value("error.404", req.URL.Path)
// "Page index.html not found!"
Contributions:
I regard this little library as feature-complete, but if you have an idea on how to improve it, feel free to create issues. Also, pull requests are welcome. Enjoy!
New creates the Lingo bundle.
Params:
Default locale, to be used when requested locale
is not found.
Path, absolute or relative path to a folder where
translation .json files are kept