Cleanup gettext usage for python code
|Reported by:||pmav99||Owned by:|
GRASS uses 3 translation domains:
_() in the builtins namespace thus making it globally available. To make i18n work, we should only need to call
gettext.install() once per translation domain.
The provided patch tries to simplify and centralize the usage of the gettext module in the python code. The main idea is that
lib/python/__init__.py should be the one and only place where
getetx.install() calls are being made. The direct consequence of this is that any python code that needs to use
_() only needs to import the
grass library first. This includes both the GUI code and the "scripts".
The patch is attached and can be applied with:
patch -p0 < gettext_cleanup.diff
The changes can also be browsed here.
In order to test this you need to:
- Enable a non-english language locale on your OS. The exact way you do that depends on your distribution. French and German are probably the best options since AFAIK they have the most complete translations, but any supported language should work.
- Configure GRASS with NLS
--with-nlsand re-compile. If NLS was not previously enabled you need to run
make distcleanbefore configuring/compiling.
- Start a GRASS session with
LC_ALL=fr_FR.utf-8 ./bin.x86_64-pc-linux-gnu/grass77(note you don't need to export any ENV variables; LC_ALL's purpose is specifically to override the values of all the other LC_* variables.source)
- your new session should now be in French. You should see the "text-based splash screen" in French. The command descriptions/options in french + the GUI in french. If not, that's a bug (or a missing translation!).
What has not been tested is the doctests. I would appreciate if someone could verify that they work and/or provide info on how to run them.