String localization tools for Go
Main use for these tools is the localization of error messages.
-
To create suitable errors use the type
Errfrom packagemistake. -
To enrich errors with context, e.g. to build kind of trace, wrap them using
fmt.Errorfand%wfrom the standard library. -
To localize, use the translation tools, e.g. function L10nLocalizeError, generated by the
l10ncommand. -
To generate and to update the JSON input file for
l10nuse thel10nextractcommand.
The older package message and the older commands stringl10n and stringl10nextract are considered deprecated.
Use "github.com/hwheinzen/stringl10n/mistake" in your project's import statements.
To get the commands l10n and l10nextract do:
$ go install github.com/hwheinzen/stringl10n/cmd/l10n@latest
$ go install github.com/hwheinzen/stringl10n/cmd/l10nextract@latest`
(But maybe you like to have all sources at hand: clone the repository then.)
Some example code can be found in cmd/l10n/example.