__init__.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. import gettext
  2. import os
  3. # Setup i18N
  4. #
  5. # Calling `gettext.install()` injects `_()` in the builtins namespace and
  6. # thus it becomes available globally (i.e. in the same process). Any python
  7. # code that needs to use _() should make sure that it firsts imports this
  8. # library.
  9. #
  10. # Note: we need to do this at the beginning of this module in order to
  11. # ensure that the injection happens before anything else gets imported.
  12. #
  13. # For more info please check the following links:
  14. # - https://docs.python.org/2/library/gettext.html#gettext.install
  15. # - https://pymotw.com/2//gettext/index.html#application-vs-module-localization
  16. # - https://www.wefearchange.org/2012/06/the-right-way-to-internationalize-your.html
  17. #
  18. _LOCALE_DIR = os.path.join(os.getenv("GISBASE"), 'locale')
  19. gettext.install('grasslibs', _LOCALE_DIR)
  20. gettext.install('grassmods', _LOCALE_DIR)
  21. gettext.install('grasswxpy', _LOCALE_DIR)
  22. __all__ = ["script", "temporal"]
  23. if os.path.exists(os.path.join(os.path.dirname(__file__), "lib", "__init__.py")):
  24. __all__.append("lib")