[GRASS-git] [OSGeo/grass] 54d46f: init: Lazy-initialize translations, fix order depe...

Vaclav Petras noreply at github.com
Sun Nov 28 17:47:33 PST 2021

  Branch: refs/heads/releasebranch_8_0
  Home:   https://github.com/OSGeo/grass
  Commit: 54d46febf1a0f5717ba0a4a794016093d7e5f5f4
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2021-11-28 (Sun, 28 Nov 2021)

  Changed paths:
    M python/grass/__init__.py

  Log Message:
  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 mailing list