12345678910111213141516171819202122232425 |
- # -*- coding: utf-8 -*-
- import gettext, os.path
- domain = "Plugin" # to be redefined
- localedir = "locale" # to be redefinded
- cur_directory = os.path.dirname(os.path.realpath(__file__))
-
-
- def locale_init(domain0=None,localedir0=None):
- global domain,localedir
- if domain0:
- domain = domain0
- if localedir0:
- localedir = os.path.join(cur_directory,localedir0)
- print "Set locale %s to %s"%(domain,localedir)
- gettext.bindtextdomain(domain, localedir)
-
-
- def _(txt):
- t = gettext.dgettext(domain, txt)
- if t == txt:
- t = gettext.gettext(txt)
- return t
-
-
|