spf13--cobra/locales/README.md
Goutte ab14efa558 feat(i18n): implement localization using gettext files
- Recipe to extract new translations from the Go code: `make i18n_extract`
- Embedded `MO` files
- Detect language from environment variables
- Some strings were pluralized
2023-12-16 10:55:52 +01:00

1.2 KiB

Locales

Localization uses embedded gettext files, defaulting to English when locale cannot be guessed from environment variables.

Development Flow

  1. Add calls to gotext.Get(…) somewhere in the codebase
  2. Run make i18n_extract
  3. Update the PO files with some software like Poedit
  4. Make sure your software has also updated the MO files

Overview

POT files

The *.pot file(s) are automatically generated by the following command :

make i18n_extract

They are named <domain>.pot, and when the domain is not specified, it is default.

PO & MO files

The actual translation files, in gettext format (*.po and *.mo), are in the directory <domain>/. They are named <language>.po and <language>.mo.

The supported <language> formats are :

The *.po files are plain text, and are the authoritative sources of translations.

The *.mo files are the ones actually packaged in cobra as embedded files, because they are smaller.