[GRASS-git] [OSGeo/grass] f4313c: init: Lazy-initialize translations, fix order depe...
noreply at github.com
Mon Nov 15 18:33:23 PST 2021
Author: Vaclav Petras <wenzeslaus at gmail.com>
Date: 2021-11-15 (Mon, 15 Nov 2021)
init: Lazy-initialize translations, fix order dependency (#1838)
In the original code, if the translation domains (GUI, lib, modules) are
ordered differently, the GUI may not be translated. The Python gettext
documentation is silent on using install with multiple domains, but separate
install calls are used to switch between different languages, so even if
multiple install calls ever resulted in all domains being used, it is not
guaranteed. The new code uses translation object directly and adds multiple
domains using fallbacks. Now GUI translations are loaded regardless of
the order of domains in the calls.
The original code requires the GISBASE variable to be set before first import
is made which makes it difficult to bootstrap. The new code delays the
initialization of translations until the first call to the translation
function removing the need to set GISBASE before the import.
A null translation as used as an ultimate fallback trying to avoid translation issues
being mixed with issues with a session/runtime setup.
The code now contains a detailed information about the current translation
approach to clarify some of the pitfalls of the current approach, specifically
the consequences of adding the translation function named underscore to
the global namespace.
More information about the grass-commit