package
0.80.2
Repository: https://github.com/azure/aks-engine-azurestack.git
Documentation: pkg.go.dev

# README

Translation and Internationalization in aks-engine-azurestack

The translation process in aks-engine-azurestack borrows some approach from Kubernetes translation. The strings to be localized are mainly the error message strings under pkg directory. Those error message strings are also consumed by other components such as ACS RP.

The localization in aks-engine-azurestack depends on github.com/leonelquinteros/gotext, a GNU gettext utility for Go. The package supports concurrency in translating strings in multiple goroutines, e.g., the same aks-engine-azurestack API called from multiple requests at the same time.

The translation files containing resource strings are packaged into aks-engine-azurestack binary using go-bindata. At runtime, the translation files are recreated on disk in the same directory as aks-engine-azurestack binary, for gotext to load.

How to add new string to be localized

When a new error string needs to be localized, it needs to use translation function Errorf in pkg/i18n/i18n.go. The locale is passed to aks-engine-azurestack API from aks-engine-azurestack command or any other component calls it. If the locale is nil, then it falls back to en-us as in the Go source file.

Once the Go source file is modified, scripts/update-translation.sh needs to be run to extract the resource strings. The script generates PO file according to the locale specified. An example of running the script is:

scripts/update-translation.sh -l en_US -p

poedit is a common tool for translation. After the PO files are translated, MO files can be generated by either poedit or tool such as msgfmt. Both PO file and MO file need to be placed under translations/<locale>/LC_MESSAGES/.

How to add a new language

When the resource strings need to be translated into a new language, the following steps are needed:

1. Use scripts/update-translation.sh with the language to genreate PO file
2. Translate the PO file and generate MO file.
3. Place PO file and MO file under `translations/<language>/LC_MESSAGES/` and commit