python类dgettext()的实例源码

region.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def get_region_name(countrycode):
    """ return translated region name from countrycode using iso3166 """
    # find translated name
    if countrycode:
        for iso in ["iso_3166", "iso_3166_2"]:
            path = os.path.join("/usr/share/xml/iso-codes/", iso + ".xml")
            if os.path.exists(path):
                root = xml.etree.ElementTree.parse(path)
                xpath = ".//%s_entry[@alpha_2_code='%s']" % (iso, countrycode)
                match = root.find(xpath)
                if match is not None:
                    name = match.attrib.get("common_name")
                    if not name:
                        name = match.attrib["name"]
                    return dgettext(iso, name)
    return ""


# the first parameter of SetRequirements
LdEpg.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _(txt):
    t = gettext.dgettext('messages', txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
LdSet.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _(txt):
    t = gettext.dgettext('messages', txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
Ipkremove.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _(txt):
    t = gettext.dgettext("XTPanel", txt)
    if t == txt:
        print "[XTPanel] fallback to default translation for", txt
        t = gettext.gettext(txt)
    return t
###############################
# Coded by PCD, February 2008 #
###############################
CCcamInfo.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _(txt):
    t = gettext.dgettext("CCcamInfo", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
__init__.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _(txt):
    t = gettext.dgettext("MountManager", txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t
__init__.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def check_incorrect_password(self, b_output):
        b_incorrect_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_ERROR_STRINGS[self._play_context.become_method]))
        return b_incorrect_password and b_incorrect_password in b_output
__init__.py 文件源码 项目:DevOps 作者: YoLoveLife 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def check_missing_password(self, b_output):
        b_missing_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_MISSING_STRINGS[self._play_context.become_method]))
        return b_missing_password and b_missing_password in b_output
SoftwareUpdate.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def doSettingsBackup(self):
        backup = None
        from Plugins.SystemPlugins.OBH.BackupManager import BackupFiles
        self.BackupFiles = BackupFiles(self.session, True)
        Components.Task.job_manager.AddJob(self.BackupFiles.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('obh', 'Backup manager'):
                break
        self.showJobView(job)
SoftwareUpdate.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def doImageBackup(self):
        backup = None
        from Plugins.SystemPlugins.OBH.ImageManager import ImageBackup
        self.ImageBackup = ImageBackup(self.session, True)
        Components.Task.job_manager.AddJob(self.ImageBackup.createBackupJob())
        Components.Task.job_manager.in_background = False
        for job in Components.Task.job_manager.getPendingJobs():
            if job.name == dgettext('obh', 'Image manager'):
                break
        self.showJobView(job)
SoftwareUpdate.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def showJobView(self, job):
        if job.name == dgettext('OBH', 'Image manager'):
            self.ImageBackupDone = True
        elif job.name == dgettext('obh', 'Backup manager'):
            self.SettingsBackupDone = True
        from Screens.TaskView import JobView
        Components.Task.job_manager.in_background = False
        if not self.autobackuprunning:
            self.session.openWithCallback(self.startActualUpgrade(("menu", "menu")), JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")
        else:
            self.session.openWithCallback(self.doAutoBackup, JobView, job,  cancelable = False, backgroundable = False, afterEventChangeable = False, afterEvent="close")
__init__.py 文件源码 项目:AutoBouquetsMaker 作者: oe-alliance 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _(txt):
    if gettext.dgettext(PluginLanguageDomain, txt):
        return gettext.dgettext(PluginLanguageDomain, txt)
    else:
        print "[" + PluginLanguageDomain + "] fallback to default translation for " + txt
        return gettext.gettext(txt)
functions.py 文件源码 项目:gnome-appfolders-manager 作者: muflone 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def text(message, gtk30=False, context=None):
    """Return a translated message and cache it for reuse"""
    if message not in localized_messages:
        if gtk30:
            # Get a message translated from GTK+ 3 domain
            full_message = message if not context else '%s\04%s' % (
                context, message)
            localized_messages[message] = dgettext('gtk30', full_message)
            # Fix for untranslated messages with context
            if context and localized_messages[message] == full_message:
                localized_messages[message] = dgettext('gtk30', message)
        else:
            localized_messages[message] = gettext(message)
    return localized_messages[message]
__init__.py 文件源码 项目:ansible-provider-docs 作者: alibaba 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def check_incorrect_password(self, b_output):
        b_incorrect_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_ERROR_STRINGS[self._play_context.become_method]))
        return b_incorrect_password and b_incorrect_password in b_output
__init__.py 文件源码 项目:ansible-provider-docs 作者: alibaba 项目源码 文件源码 阅读 71 收藏 0 点赞 0 评论 0
def check_missing_password(self, b_output):
        b_missing_password = to_bytes(gettext.dgettext(self._play_context.become_method, C.BECOME_MISSING_STRINGS[self._play_context.become_method]))
        return b_missing_password and b_missing_password in b_output
i18n.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def langcode_to_name(langcode):
    import xml.etree.ElementTree
    from gettext import dgettext
    for iso in ["iso_639_3", "iso_639"]:
        path = os.path.join("/usr/share/xml/iso-codes/", iso + ".xml")
        if os.path.exists(path):
            root = xml.etree.ElementTree.parse(path)
            xpath = ".//%s_entry[@part1_code='%s']" % (iso, langcode)
            match = root.find(xpath)
            if match is not None:
                return dgettext(iso, match.attrib["name"])
    return langcode
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _init_submit(self):
        self.submit_window.set_title(_("Review %s") %
            gettext.dgettext("app-install-data", self.app.name))
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _init_modify(self):
        self._populate_review()
        self.submit_window.set_title(_("Modify Your %(appname)s Review") % {
            'appname': gettext.dgettext("app-install-data", self.app.name)})
        self.button_post.set_label(_("Modify"))
        self.SUBMIT_MESSAGE = _("Updating your review")
        self.FAILURE_MESSAGE = _("Failed to edit review")
        self.SUCCESS_MESSAGE = _("Review updated")
        self._enable_or_disable_post_button()
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _setup_details(self, widget, app, iconname, version, display_name):
        # icon shazam
        try:
            icon = self.icons.load_icon(iconname, self.APP_ICON_SIZE, 0)
        except:
            icon = self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE,
                0)
        self.review_appicon.set_from_pixbuf(icon)

        # title
        app = utf8(gettext.dgettext("app-install-data", app.name))
        version = utf8(version)
        self.review_title.set_markup(
            '<b><span size="x-large">%s</span></b>\n%s' % (app, version))

        # review label
        self.review_label.set_markup(_('Review by: %s') %
            display_name.encode('utf8'))

        # review summary label
        self.review_summary_label.set_markup(_('Summary:'))

        #rating label
        self.rating_label.set_markup(_('Rating:'))
        #error detail link label
        self.label_expander.set_markup('<small><u>%s</u></small>' %
            (_('Error Details')))
update.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_desktop(self, key, translated=True):
        " get generic option under 'Desktop Entry'"
        # never translate the pkgname
        if key == "X-AppInstall-Package":
            return self.get(self.DE, key)
        # shortcut
        if not translated:
            return self.get(self.DE, key)
        # first try dgettext
        if self.has_option_desktop("X-Ubuntu-Gettext-Domain"):
            value = self.get(self.DE, key)
            if value:
                domain = self.get(self.DE, "X-Ubuntu-Gettext-Domain")
                translated_value = gettext.dgettext(domain, value)
                if value != translated_value:
                    return translated_value
        # then try app-install-data
        value = self.get(self.DE, key)
        if value:
            translated_value = gettext.dgettext("app-install-data", value)
            if value != translated_value:
                return translated_value
        # then try the i18n version of the key (in [de_DE] or
        # [de]) but ignore errors and return the untranslated one then
        try:
            locale = getdefaultlocale(('LANGUAGE', 'LANG', 'LC_CTYPE',
                'LC_ALL'))[0]
            if locale:
                if self.has_option_desktop("%s[%s]" % (key, locale)):
                    return self.get(self.DE, "%s[%s]" % (key, locale))
                if "_" in locale:
                    locale_short = locale.split("_")[0]
                    if self.has_option_desktop("%s[%s]" % (key, locale_short)):
                        return self.get(self.DE, "%s[%s]" %
                            (key, locale_short))
        except ValueError:
            pass
        # and then the untranslated field
        return self.get(self.DE, key)
i18n.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def langcode_to_name(langcode):
    import xml.etree.ElementTree
    from gettext import dgettext
    for iso in ["iso_639_3", "iso_639"]:
        path = os.path.join("/usr/share/xml/iso-codes/", iso + ".xml")
        if os.path.exists(path):
            root = xml.etree.ElementTree.parse(path)
            xpath = ".//%s_entry[@part1_code='%s']" % (iso, langcode)
            match = root.find(xpath)
            if match is not None:
                return dgettext(iso, match.attrib["name"])
    return langcode
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _init_submit(self):
        self.submit_window.set_title(_("Review %s") %
            gettext.dgettext("app-install-data", self.app.name))
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _init_modify(self):
        self._populate_review()
        self.submit_window.set_title(_("Modify Your %(appname)s Review") % {
            'appname': gettext.dgettext("app-install-data", self.app.name)})
        self.button_post.set_label(_("Modify"))
        self.SUBMIT_MESSAGE = _("Updating your review")
        self.FAILURE_MESSAGE = _("Failed to edit review")
        self.SUCCESS_MESSAGE = _("Review updated")
        self._enable_or_disable_post_button()
review_gui_helper.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _setup_details(self, widget, app, iconname, version, display_name):
        # icon shazam
        try:
            icon = self.icons.load_icon(iconname, self.APP_ICON_SIZE, 0)
        except:
            icon = self.icons.load_icon(Icons.MISSING_APP, self.APP_ICON_SIZE,
                0)
        self.review_appicon.set_from_pixbuf(icon)

        # title
        app = utf8(gettext.dgettext("app-install-data", app.name))
        version = utf8(version)
        self.review_title.set_markup(
            '<b><span size="x-large">%s</span></b>\n%s' % (app, version))

        # review label
        self.review_label.set_markup(_('Review by: %s') %
            display_name.encode('utf8'))

        # review summary label
        self.review_summary_label.set_markup(_('Summary:'))

        #rating label
        self.rating_label.set_markup(_('Rating:'))
        #error detail link label
        self.label_expander.set_markup('<small><u>%s</u></small>' %
            (_('Error Details')))
update.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_desktop(self, key, translated=True):
        # strip away bogus prefixes
        if key.startswith("X-AppInstall-"):
            key = key[len("X-AppInstall-"):]
        # shortcut
        if not translated:
            return self.tag_section[key]
        # FIXME: make i18n work similar to get_desktop
        # first try dgettext
        if "Gettext-Domain" in self.tag_section:
            value = self.tag_section.get(key)
            if value:
                domain = self.tag_section["Gettext-Domain"]
                translated_value = gettext.dgettext(domain, value)
                if value != translated_value:
                    return translated_value
        # then try the i18n version of the key (in [de_DE] or
        # [de]) but ignore errors and return the untranslated one then
        try:
            locale = getdefaultlocale(('LANGUAGE', 'LANG', 'LC_CTYPE',
                'LC_ALL'))[0]
            if locale:
                if self.has_option_desktop("%s-%s" % (key, locale)):
                    return self.tag_section["%s-%s" % (key, locale)]
                if "_" in locale:
                    locale_short = locale.split("_")[0]
                    if self.has_option_desktop("%s-%s" % (key, locale_short)):
                        return self.tag_section["%s-%s" % (key, locale_short)]
        except ValueError:
            pass
        # and then the untranslated field
        return self.tag_section[key]
update.py 文件源码 项目:x-mario-center 作者: fossasia 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_desktop(self, key, translated=True):
        " get generic option under 'Desktop Entry'"
        # never translate the pkgname
        if key == "X-AppInstall-Package":
            return self.get(self.DE, key)
        # shortcut
        if not translated:
            return self.get(self.DE, key)
        # first try dgettext
        if self.has_option_desktop("X-Ubuntu-Gettext-Domain"):
            value = self.get(self.DE, key)
            if value:
                domain = self.get(self.DE, "X-Ubuntu-Gettext-Domain")
                translated_value = gettext.dgettext(domain, value)
                if value != translated_value:
                    return translated_value
        # then try app-install-data
        value = self.get(self.DE, key)
        if value:
            translated_value = gettext.dgettext("app-install-data", value)
            if value != translated_value:
                return translated_value
        # then try the i18n version of the key (in [de_DE] or
        # [de]) but ignore errors and return the untranslated one then
        try:
            locale = getdefaultlocale(('LANGUAGE', 'LANG', 'LC_CTYPE',
                'LC_ALL'))[0]
            if locale:
                if self.has_option_desktop("%s[%s]" % (key, locale)):
                    return self.get(self.DE, "%s[%s]" % (key, locale))
                if "_" in locale:
                    locale_short = locale.split("_")[0]
                    if self.has_option_desktop("%s[%s]" % (key, locale_short)):
                        return self.get(self.DE, "%s[%s]" %
                            (key, locale_short))
        except ValueError:
            pass
        # and then the untranslated field
        return self.get(self.DE, key)
__init__.py 文件源码 项目:HRTunerProxy 作者: OpenViX 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _(txt):
    if gettext.dgettext(PluginLanguageDomain, txt):
        return gettext.dgettext(PluginLanguageDomain, txt)
    else:
        print "[" + PluginLanguageDomain + "] fallback to default translation for " + txt
        return gettext.gettext(txt)
elib_intl.py 文件源码 项目:chirp_fork 作者: mach327 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _dugettext(domain, message):
    '''
    :param domain: translation domain
    :param message: message to translate
    :returns: the translated message

    Unicode version of :func:`gettext.dgettext`.
    '''
    try:
        t = gettext.translation(domain, gettext._localedirs.get(domain, None),
                                codeset=gettext._localecodesets.get(domain))
    except IOError:
        return message
    else:
        return t.ugettext(message)
GDebiKDE.py 文件源码 项目:gdebi 作者: linuxmint 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __(catalog,str):
    return utf8(gettext.dgettext(catalog, str))
iptvplayerinit.py 文件源码 项目:crossplatform_iptvplayer 作者: j00zek 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def TranslateTXT(txt):
    t = gettext.dgettext(PluginLanguageDomain, txt)
    if t == txt:
        t = gettext.gettext(txt)
    return t


问题


面经


文章

微信
公众号

扫码关注公众号