-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
0e43bf3
commit f4313c4
Showing
1 changed file
with
94 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters