当前位置: 首页>>代码示例>>Python>>正文


Python gettext.bindtextdomain方法代码示例

本文整理汇总了Python中gettext.bindtextdomain方法的典型用法代码示例。如果您正苦于以下问题:Python gettext.bindtextdomain方法的具体用法?Python gettext.bindtextdomain怎么用?Python gettext.bindtextdomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gettext的用法示例。


在下文中一共展示了gettext.bindtextdomain方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_locale

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def load_locale():
    import gettext
    from importlib.resources import path

    # Load pre-installed translation
    with path('tuijam', 'lang') as locale_path:
        locale = gettext.find('tuijam', locale_path)
        if locale is not None:
            gettext.bindtextdomain('tuijam', locale_path)
            gettext.textdomain('tuijam')

    # Then load user translation
    locale = gettext.find('tuijam', LOCALE_DIR)
    if locale is not None:
        gettext.bindtextdomain('tuijam', LOCALE_DIR)
        gettext.textdomain('tuijam') 
开发者ID:cfangmeier,项目名称:tuijam,代码行数:18,代码来源:app.py

示例2: setUp

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def setUp(self):
        GettextBaseTest.setUp(self)
        self.localedir = os.curdir
        # Set up the bindings
        gettext.bindtextdomain('gettext', self.localedir)
        gettext.textdomain('gettext')
        # For convenience
        self._ = gettext.gettext 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_gettext.py

示例3: test_bindtextdomain

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def test_bindtextdomain(self):
        self.assertEqual(gettext.bindtextdomain('gettext'), self.localedir) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_gettext.py

示例4: _initGettext

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def _initGettext():
    charset = initLocale()

    # Try to load gettext module
    if config.use_i18n:
        try:
            import gettext
            ok = True
        except ImportError:
            ok = False
    else:
        ok = False

    # gettext is not available or not needed: use dummy gettext functions
    if not ok:
        return (_dummy_gettext, _dummy_ngettext)

    # Gettext variables
    package = hachoir_core.PACKAGE
    locale_dir = path.join(path.dirname(__file__), "..", "locale")

    # Initialize gettext module
    gettext.bindtextdomain(package, locale_dir)
    gettext.textdomain(package)
    translate = gettext.gettext
    ngettext = gettext.ngettext

    # TODO: translate_unicode lambda function really sucks!
    # => find native function to do that
    unicode_gettext = lambda text: \
        unicode(translate(text), charset)
    unicode_ngettext = lambda singular, plural, count: \
        unicode(ngettext(singular, plural, count), charset)
    return (unicode_gettext, unicode_ngettext) 
开发者ID:Yukinoshita47,项目名称:Yuki-Chan-The-Auto-Pentest,代码行数:36,代码来源:i18n.py

示例5: init_locale

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def init_locale(localedir=None):
	"""
	Initializes gettext-related stuff
	"""
	global _localedir
	_localedir = localedir
	gettext.bindtextdomain(GETTEXT_DOMAIN, localedir)
	gettext.bind_textdomain_codeset(GETTEXT_DOMAIN, "utf-8")
	gettext.textdomain(GETTEXT_DOMAIN) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:11,代码来源:tools.py

示例6: switch_locale

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def switch_locale(self, locale_type):
            """
            Change the locale
            """
            locale.setlocale(locale.LC_ALL, '')
            locale.bindtextdomain(locale_type, RB.locale_dir())
            locale.textdomain(locale_type)
            gettext.bindtextdomain(locale_type, RB.locale_dir())
            gettext.textdomain(locale_type)
            gettext.install(locale_type) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:12,代码来源:alttoolbar_preferences.py

示例7: localeInit

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def localeInit():
	if isDreamOS: # check if opendreambox image
		lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
		os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
	gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath)) 
开发者ID:OpenViX,项目名称:HRTunerProxy,代码行数:7,代码来源:__init__.py

示例8: localeInit

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def localeInit():
	gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath)) 
开发者ID:oe-alliance,项目名称:AutoBouquetsMaker,代码行数:4,代码来源:__init__.py

示例9: set_locale

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def set_locale(self, textdomain, msgs_path, locale='system'):
        msgs_path = msgs_path.decode('utf8') \
            if not (msgs_path, unicode) else msgs_path
        if locale == 'en' or not os.path.exists(msgs_path):
            return
        if locale and not locale == 'system':
            os.environ['LANGUAGE'] = locale
        gettext.bindtextdomain(textdomain, msgs_path)
        gettext.textdomain(textdomain)
        self.translate = gettext.gettext 
开发者ID:sk1project,项目名称:uniconvertor,代码行数:12,代码来源:translator.py

示例10: __init__

# 需要导入模块: import gettext [as 别名]
# 或者: from gettext import bindtextdomain [as 别名]
def __init__(self):

        setproctitle.setproctitle("GPT")
        self.install_dir = os.getcwd()
        self.user_app_dir = os.path.join(os.path.expanduser("~"),
                                         ".config",
                                         "gpt",
                                         )
        # create hidden app folder in user"s home directory if it does
        # not exist
        if not os.path.isdir(self.user_app_dir):
            os.makedirs(self.user_app_dir)

        # initiate GTK+ application
        GLib.set_prgname("GPT")

        # set up logging
        os.chdir(self.user_app_dir)
        self.log = logging.getLogger("gpt")
        with open(os.path.join(self.install_dir, "logging.yaml")) as f:
            config = yaml.load(f)
            logging.config.dictConfig(config)

        self.loglevels = {"critical": 50,
                          "error": 40,
                          "warning": 30,
                          "info": 20,
                          "debug": 10,
                          }

        # log version info for debugging
        self.log.debug("Application version: {}".format(__version__))
        self.log.debug("GTK+ version: {}.{}.{}".format(Gtk.get_major_version(),
                                                          Gtk.get_minor_version(),
                                                          Gtk.get_micro_version(),
                                                          ))
        self.log.debug(_("Application executed from {}").format(self.install_dir))

        self.locales_dir = os.path.join(self.install_dir, "po", "locale")
        self.appname = "GPT"

        # setting up localization
        locale.bindtextdomain(self.appname, self.locales_dir)
        locale.textdomain(self.locales_dir)
        gettext.bindtextdomain(self.appname, self.locales_dir)
        gettext.textdomain(self.appname)

        # check for config file to set up working directory
        # create file in case it does not exist
        self.config = os.path.join(self.user_app_dir, "config.py")
        self.defaultwdir = os.path.join(os.path.expanduser("~"), "GP")

        if os.path.isfile(self.config):
            self.readconfig()
        else:
            self.stdir = self.defaultwdir
            self.chkdir(self.stdir)
            self.createconfig(self.stdir)
            self.kd_supp = True

        self.show_message(_("Working directory: {}").format(self.stdir)) 
开发者ID:encarsia,项目名称:gpt,代码行数:63,代码来源:modules.py


注:本文中的gettext.bindtextdomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。