[GRASS-dev] [GRASS GIS] #3790: Cleanup gettext usage for python code

GRASS GIS trac at osgeo.org
Tue Mar 12 04:45:19 PDT 2019


#3790: Cleanup gettext usage for python code
-------------------------+-------------------------
 Reporter:  pmav99       |      Owner:  grass-dev@…
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:
Component:  Python       |    Version:  svn-trunk
 Keywords:               |        CPU:  Unspecified
 Platform:  Unspecified  |
-------------------------+-------------------------
 GRASS uses 3 translation domains:
 - grasslibs
 - grassmods
 - grasswxpy

 Calling {{{gettext.install()}}} injects {{{_()}}} 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 [https://github.com/GRASS-GIS/grass-
 ci/pull/9 here].

 In order to test this you need to:

 1. 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.
 2. Configure GRASS with NLS {{{--with-nls}}} and re-compile. If NLS was
 not previously enabled you need to run {{{make distclean}}} before
 configuring/compiling.
 3. 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.[https://wiki.archlinux.org/index.php/Locale#LC_ALL:_troubleshooting
 source])
 4. 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.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3790>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list