Enigma2 plugin to to play various online streams (mostly Latvian).

plugin_locale.py 595B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. import gettext, os.path
  3. domain = "Plugin" # to be redefined
  4. localedir = "locale" # to be redefinded
  5. cur_directory = os.path.dirname(os.path.realpath(__file__))
  6. def locale_init(domain0=None,localedir0=None):
  7. global domain,localedir
  8. if domain0:
  9. domain = domain0
  10. if localedir0:
  11. localedir = os.path.join(cur_directory,localedir0)
  12. print "Set locale %s to %s"%(domain,localedir)
  13. gettext.bindtextdomain(domain, localedir)
  14. def _(txt):
  15. t = gettext.dgettext(domain, txt)
  16. if t == txt:
  17. t = gettext.gettext(txt)
  18. return t