As in the pkg-tree implementation, the walking of different dependencies
are not determinated, this means that we may have references swapping
between consecutive runs. Ensure we always order them the same way now.
Ensure we follow the same rule when exporting to text format.
This allows multi-line exports following the convention of single line,
EOL at the end of the string and more.
The extraction of gettext entry does not translate properly multiline nor
backquotes:
* Multilines are printed as is, instead of follow the gettext spec:
https://www.gnu.org/software/gettext/manual/html_node/Normalizing.html
* Strings with backquotes as printed as “msgid `this is my string`”,
* Multilines strings with backquotes are formatted as multi-lines to, without
closing quotes on each lines.
The loading is correct though, this only impact the generation file.
Those generated files are thus then invalid and can’t be compile to mo file.
By setting globalConfig.storage object, it's up to the loading wrapper to set
Locale.Domains map to desired manually loaded Translators like embedding po as
[]bytes or so, using dedicated files…
Then, the project can use gotext.Get() or any root level methods
transparently.
This is very useful if you want to test your code from your own repo (using
embedded po files if you detect the root of your projects), while still being
able to build your project and deploy to an installation, which will load from
/usr/share/…
Fixes: #52.
gettext supports supplying multiple languages using the colon character
$ LC_ALL=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.
This patch adds .IsTranslated(), .IsTranslatedN() and related functions
to following objects:
- Po
- Mo
- locale
- gotext
and it creates helper interfaces in introspector.go.
This makes it possible to detect whether a string is translatable or not
during runtime.
Resolves#42
This patch adds .IsTranslated(), .IsTranslatedN() and related functions
to following objects:
- Translation
- Domain
This makes it possible to detect whether a string is translatable or not
during runtime.