Documentation
¶
Overview ¶
Package i18n ships ready translations of every error message the library and its plugins declare, in 21 languages beside English, as an auth.Messages catalogue:
a, err := auth.New(..., auth.WithMessages(i18n.Messages()))
The catalogue only changes the message: the code and the status of an error never change, so a client that matches codes sees no difference, and a code a locale does not translate (a plugin added after the translation) keeps its declared English message rather than an empty one. An app that wants its own voice merges or replaces entries: Messages returns a fresh map on every call, so editing it changes nothing anyone else holds.
The translations live in locales/<tag>.json, one object of code to message per language, the same shape as docs/reference/error-codes.json lists the English ones in, so a file can be corrected or added without touching Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Locales = []string{"ar", "bn", "de", "es", "fa", "fr", "hi", "id", "it", "ja", "ko", "nl", "pl", "pt", "ru", "sv", "th", "tr", "uk", "vi", "zh"}
Locales lists the tags Messages translates into, sorted: Arabic, Bengali, German, Spanish, Persian, French, Hindi, Indonesian, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Russian, Swedish, Thai, Turkish, Ukrainian, Vietnamese and Chinese (Simplified). English is not in it: the declared messages are English, and a request in English gets them.
Functions ¶
func Messages ¶
Messages returns the catalogue of every shipped locale, for auth.WithMessages. The lookup is auth.Messages': the request's exact tag, then its base language, so "pt-BR" and "zh-CN" find "pt" and "zh".
It panics if an embedded file does not parse, which only a broken build can cause: the files are compiled in and a test parses every one.
Types ¶
This section is empty.