/stringl10n

Simple string localization via go:generate and text/template

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

stringl10n

String localization tools for Go

Main use for these tools is the localization of error messages.

  • To create suitable errors use the type Err from package mistake.

  • To enrich errors with context, e.g. to build kind of trace, wrap them using fmt.Errorf and %w from the standard library.

  • To localize, use the translation tools, e.g. function L10nLocalizeError, generated by the l10n command.

  • To generate and to update the JSON input file for l10n use the l10nextract command.

OBSOLETE

The older package message and the older commands stringl10n and stringl10nextract are considered deprecated.

Usage

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.)

Example

Some example code can be found in cmd/l10n/example.