Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gettext supports supplying multiple languages using the colon character $ LANGUAGE=pt_BR:pt_PT:en_US foo bar which are used as fallback: when a translation for the first one is not available, the second language is used. If no language contains a translation for the string `msgid` is returned. This patch adds this support into gotext. 1/ config struct - 'language' was renamed to 'languages' and is a slice of strings - 'storage' was renamed to 'locales' and is a slice of Locale pointers 2/ loadStorage() - all loaded languages are iterated over 3/ GetLanguages() - new function returns the languages from the config - GetLanguage() uses the first element of it, keeping the compatibility 4/ SetLanguage(), Configure() - the language string is split at colon and iterated over 5/ Get*() - languages are iterated and the first translation for given string is returned 6/ IsTranslated*() - new optional parameter (langs) has been added 7/ Locale.GetActualLanguage() - it checks the filesystem and determines what the actual language code is: for 'cs_CZ', just 'cs' may be returned, depending on the actual name of the .mo/.po file. 8/ GetLocales/GetStorage, SetLocales/SetStorage - Following recent changes, created public functions to manipulate with global configuration's locales. The *Storage functions are renamed in later commit to reduce the amount of changes in one commit.
- Loading branch information