• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python gtcache.ngettext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中miro.gtcache.ngettext函数的典型用法代码示例。如果您正苦于以下问题:Python ngettext函数的具体用法?Python ngettext怎么用?Python ngettext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: make_progress

        def make_progress():
            if self.cancelled:
                self.gathered_media_files = []
                self.finder = None
                progress_label.set_text("")
                return

            try:
                num_parsed, found = self.finder.next()
                self.gathered_media_files = found

                num_found = len(found)
                num_files = ngettext("parsed %(count)s file",
                        "parsed %(count)s files",
                        num_parsed,
                        {"count": num_parsed})

                num_media_files = ngettext("found %(count)s media file",
                        "found %(count)s media files",
                        num_found,
                        {"count": num_found})
                progress_label.set_text(u"%s - %s" % (num_files,
                                                      num_media_files))

                threads.call_on_ui_thread(make_progress)

            except StopIteration:
                handle_cancel_clicked(None)
                self.finder = None
开发者ID:cool-RR,项目名称:Miro,代码行数:29,代码来源:firsttimedialog.py


示例2: _update_full_section

    def _update_full_section(self, downloads, items, autoqueued_count):
        if self._search_text == '':
            itemtext = ngettext("%(count)d Item",
                                "%(count)d Items",
                                items,
                                {"count": items})
            downloadingtext = ngettext("%(count)d Downloading",
                                       "%(count)d Downloading",
                                       downloads,
                                       {"count": downloads})
            if autoqueued_count:
                queuedtext = ngettext("%(count)d Download Queued Due To "
                                      "Unplayed Items (See Settings)",
                                      "%(count)d Downloads Queued Due To "
                                      "Unplayed Items (See Settings)",
                                      autoqueued_count,
                                      {"count": autoqueued_count})

            text = u"|  %s" % itemtext
            if downloads:
                text = text + u"  |  %s" % downloadingtext
            if autoqueued_count:
                text = text + u"  |  %s" % queuedtext
        else:
            text = ngettext("%(count)d Item Matches Search",
                    "%(count)d Items Match Search",
                    items, {"count": items})
            text = u"|  %s" % text
        self.full_section.set_info(text)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:29,代码来源:feedcontroller.py


示例3: get_formatted_default_expiration

def get_formatted_default_expiration():
    """Returns the 'system' expiration delay as a formatted string
    """
    expiration = float(app.config.get(prefs.EXPIRE_AFTER_X_DAYS))
    formatted_expiration = u''
    if expiration < 0:
        formatted_expiration = _('never')
    elif expiration < 1.0:
        hours = int(expiration * 24.0)
        formatted_expiration = ngettext("%(count)d hour ago",
                                        "%(count)d hours ago",
                                        hours,
                                        {"count": hours})
    elif expiration >= 1 and expiration < 30:
        days = int(expiration)
        formatted_expiration = ngettext("%(count)d day ago",
                                        "%(count)d days ago",
                                        days,
                                        {"count": days})
    elif expiration >= 30:
        months = int(expiration / 30)
        formatted_expiration = ngettext("%(count)d month ago",
                                        "%(count)d months ago",
                                        months,
                                        {"count": months})
    return formatted_expiration
开发者ID:nxmirrors,项目名称:miro,代码行数:26,代码来源:feedsettingspanel.py


示例4: test_ngettext

    def test_ngettext(self):
        # french uses singular for 0, 1 and plural for everything else.
        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 0),
                         u'%(count)d vid\xe9o trouv\xe9e')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 1),
                         u'%(count)d vid\xe9o trouv\xe9e')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 2),
                         u'%(count)d vid\xe9os trouv\xe9es')
开发者ID:cool-RR,项目名称:Miro,代码行数:13,代码来源:gtcachetest.py


示例5: _build_progress_label

    def _build_progress_label(self, num_found, num_parsed):
            num_files = ngettext(
                "Searched %(count)s file",
                "Searched %(count)s files",
                num_parsed,
                {"count": num_parsed})

            num_media_files = ngettext(
                "found %(count)s media file",
                "found %(count)s media files",
                num_found,
                {"count": num_found})

            return u"%s - %s" % (num_files, num_media_files)
开发者ID:CodeforEvolution,项目名称:miro,代码行数:14,代码来源:searchfilesdialog.py


示例6: time_string

def time_string(secs):
    if secs >= (60 * 60 * 24):
        t_dy = secs * 1.0 / (60 * 60 * 24)
        return ngettext('%(num).0f day', '%(num).0f days', int(t_dy),
                        {"num": t_dy})
    if secs >= (60 * 60):
        t_hr = secs * 1.0 / (60 * 60)
        return ngettext('%(num).0f hr', '%(num).0f hrs', int(t_hr),
                        {"num": t_hr})
    if secs >= 60:
        t_min = secs * 1.0 / 60
        return ngettext('%(num).0f min', '%(num).0f mins', int(t_min),
                        {"num": t_min})

    return ngettext('%(num)d sec', '%(num)d secs', secs, {"num": secs})
开发者ID:nxmirrors,项目名称:miro,代码行数:15,代码来源:displaytext.py


示例7: _update_downloading_section

 def _update_downloading_section(self, downloads):
     if downloads > 0:
         text = ngettext("%(count)d Downloading", "%(count)d Downloading", downloads, {"count": downloads})
         self.downloading_section.set_header(text)
         self.downloading_section.show()
     else:
         self.downloading_section.hide()
开发者ID:nerdymcgee,项目名称:miro,代码行数:7,代码来源:feedcontroller.py


示例8: show_import_summary

 def show_import_summary(self):
     imported_feeds = len(self.result[0].get('feed', []))
     ignored_feeds = len(self.result[1].get('feed', []))
     title = _("OPML Import summary")
     message = ngettext("Successfully imported %(count)d feed.",
                        "Successfully imported %(count)d feeds.",
                        imported_feeds,
                        {"count": imported_feeds})
     if self.ignored_feeds > 0:
         message += "\n"
         message += ngettext("Skipped %(count)d feed already present.",
                             "Skipped %(count)d feeds already present.",
                             ignored_feeds,
                             {"count": ignored_feeds})
     dialog = dialogs.MessageBoxDialog(title, message)
     dialog.run()
开发者ID:cool-RR,项目名称:Miro,代码行数:16,代码来源:opml.py


示例9: make_search_progress

    def make_search_progress(self):
        if self.cancelled:
            self.finder = None
            return

        try:
            num_parsed, found = self.finder.next()
            self.gathered_media_files = found

            num_found = len(found)
            num_files = ngettext("parsed %(count)s file",
                    "parsed %(count)s files",
                    num_parsed,
                    {"count": num_parsed})

            num_media_files = ngettext("found %(count)s media file",
                    "found %(count)s media files",
                    num_found,
                    {"count": num_found})
            self.progress_label.set_text(u"%s - %s" % (
                    num_files, num_media_files))

            threads.call_on_ui_thread(self.make_search_progress)

        except StopIteration:
            num_found = len(self.gathered_media_files)
            self.search_complete(
                ngettext(
                    "found %(count)s media file",
                    "found %(count)s media files",
                    num_found,
                    {"count": num_found}))
            self.finder = None

        except Exception:
            # this is here to get more data for bug #17422
            logging.exception("exception thrown in make_search_progress")

            # we want to clean up after this exception, too.
            num_found = len(self.gathered_media_files)
            self.search_complete(
                ngettext(
                    "found %(count)s media file",
                    "found %(count)s media files",
                    num_found,
                    {"count": num_found}))
            self.finder = None
开发者ID:codito,项目名称:miro,代码行数:47,代码来源:firsttimedialog.py


示例10: _update_downloaded_section

 def _update_downloaded_section(self, watchable):
     if watchable > 0:
         text = ngettext("%(count)d Item", "%(count)d Items", watchable, {"count": watchable})
         text = u"|  %s  " % text
         self.downloaded_section.set_info(text)
         self.downloaded_section.show()
     else:
         self.downloaded_section.hide()
开发者ID:nerdymcgee,项目名称:miro,代码行数:8,代码来源:feedcontroller.py


示例11: expiration_date_short

def expiration_date_short(exp_date):
    offset = exp_date - datetime.datetime.now()
    if offset.days > 0:
        return ngettext("Expires: %(count)d day",
                        "Expires: %(count)d days",
                        offset.days,
                        {"count": offset.days})
    elif offset.seconds > 3600:
        return ngettext("Expires: %(count)d hour",
                        "Expires: %(count)d hours",
                        math.ceil(offset.seconds/3600.0),
                        {"count": math.ceil(offset.seconds/3600.0)})
    else:
        return ngettext("Expires: %(count)d minute",
                        "Expires: %(count)d minutes",
                        math.ceil(offset.seconds/60.0),
                        {"count": math.ceil(offset.seconds/60.0)})
开发者ID:nxmirrors,项目名称:miro,代码行数:17,代码来源:displaytext.py


示例12: test_ngettext_counts

    def test_ngettext_counts(self):
        # test that it always truncates the count arg and we
        # should always get the singular form.
        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 1.0),
                         u'%(count)d vid\xe9o trouv\xe9e')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 1.5),
                         u'%(count)d vid\xe9o trouv\xe9e')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 1.9),
                         u'%(count)d vid\xe9o trouv\xe9e')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 2.0),
                         u'%(count)d vid\xe9os trouv\xe9es')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 2.5),
                         u'%(count)d vid\xe9os trouv\xe9es')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", 2.9),
                         u'%(count)d vid\xe9os trouv\xe9es')

        self.assertEqual(gtcache.ngettext("%(count)d video found",
                                          "%(count)d videos found", int(2.5)),
                         u'%(count)d vid\xe9os trouv\xe9es')
开发者ID:codito,项目名称:miro,代码行数:30,代码来源:gtcachetest.py


示例13: current_sync_information

 def current_sync_information(self, video_count, audio_count):
     if video_count == 0 and audio_count == 0:
         self.sync_state.set_text(_('Up to date'))
         self.sync_button.disable()
     else:
         self.sync_button.enable()
         counts = []
         if video_count:
             counts.append(ngettext('%(count)d video file',
                                    '%(count)d video files',
                                    video_count,
                                    {"count": video_count}))
         if audio_count:
             counts.append(ngettext('%(count)d audio file',
                                    '%(count)d audio files',
                                    audio_count,
                                    {"count": audio_count}))
         self.sync_state.set_text('\n'.join(counts))
开发者ID:cool-RR,项目名称:Miro,代码行数:18,代码来源:devicecontroller.py


示例14: expiration_date_short

def expiration_date_short(exp_date):
    offset = exp_date - datetime.datetime.now()
    if offset.days > 0:
        return ngettext("Expires: %(count)d day",
                        "Expires: %(count)d days",
                        offset.days,
                        {"count": offset.days})
    elif offset.seconds > 3600:
        hours = int(round(offset.seconds / 3600.0))
        return ngettext("Expires: %(count)d hour",
                        "Expires: %(count)d hours",
                        hours,
                        {"count": hours})
    else:
        minutes = int(round(offset.seconds / 60.0))
        return ngettext("Expires: %(count)d minute",
                        "Expires: %(count)d minutes",
                        minutes,
                        {"count": minutes})
开发者ID:CodeforEvolution,项目名称:miro,代码行数:19,代码来源:displaytext.py


示例15: test_ngettext_values

    def test_ngettext_values(self):
        # try the bad translation with no values
        self.assertEqual(gtcache.ngettext("bad %(count)d video found",
                                          "bad %(count)d videos found", 0),
                         u'bad %(count) vid\xe9o trouv\xe9e')

        # try the bad translation with values
        self.assertEqual(gtcache.ngettext("bad %(count)d video found",
                                          "bad %(count)d videos found", 0,
                                          {"count": 0}),
                         u'bad 0 videos found')

        self.assertEqual(gtcache.ngettext("bad %(count)d video found",
                                          "bad %(count)d videos found", 1,
                                          {"count": 1}),
                         u'bad 1 video found')

        self.assertEqual(gtcache.ngettext("bad %(count)d video found",
                                          "bad %(count)d videos found", 2,
                                          {"count": 2}),
                         u'bad 2 videos found')
开发者ID:cool-RR,项目名称:Miro,代码行数:21,代码来源:gtcachetest.py


示例16: set_sync_state

 def set_sync_state(self, count):
     if self.in_progress:
         # don't update sync state while we're syncing
         return
     if count:
         self.sync_label.set_text(
             ngettext('1 file selected to sync',
                      '%(count)i files selected to sync',
                      count,
                      {'count': count}))
         self.sync_button.enable()
     else:
         self.sync_label.set_text(_("Up to date"))
         self.sync_button.disable()
开发者ID:kmshi,项目名称:miro,代码行数:14,代码来源:devicecontroller.py


示例17: set_sync_state

 def set_sync_state(self, count):
     if self.in_progress:
         # don't update sync state while we're syncing
         return
     if count:
         self.sync_button.set_text(
             ngettext('Sync 1 File',
                      'Sync %(count)i Files',
                      count,
                      {'count': count}))
         self.sync_button.enable()
     else:
         self.sync_button.set_text(_("Up to date"))
         self.sync_button.disable()
开发者ID:CodeforEvolution,项目名称:miro,代码行数:14,代码来源:devicecontroller.py


示例18: make_search_progress

    def make_search_progress(self):
        if self.cancelled:
            self.finder = None
            return

        try:
            num_parsed, found = self.finder.next()
            self.gathered_media_files = found

            num_found = len(found)
            num_files = ngettext("parsed %(count)s file",
                    "parsed %(count)s files",
                    num_parsed,
                    {"count": num_parsed})

            num_media_files = ngettext("found %(count)s media file",
                    "found %(count)s media files",
                    num_found,
                    {"count": num_found})
            self.progress_label.set_text(u"%s - %s" % (
                    num_files, num_media_files))

            threads.call_on_ui_thread(self.make_search_progress)

        except StopIteration:
            if self.gathered_media_files:
                num_found = len(self.gathered_media_files)
            else:
                num_found = 0
            self.search_complete(
                ngettext(
                    "found %(count)s media file",
                    "found %(count)s media files",
                    num_found,
                    {"count": num_found}))
            self.finder = None
开发者ID:bbucommander,项目名称:miro,代码行数:36,代码来源:firsttimedialog.py


示例19: _make_label

    def _make_label(self, tab_type, selected_tabs):
        label_parts = []
        # NOTE: we need to use ngettext because some languages have multiple
        # plural forms.
        if self.folder_count > 0:
            if tab_type == 'feed':
                label_parts.append(ngettext(
                        '%(count)d Podcast Folder Selected',
                        '%(count)d Podcast Folders Selected',
                        self.folder_count,
                        {"count": self.folder_count}))
                label_parts.append(ngettext(
                        '(contains %(count)d podcast)',
                        '(contains %(count)d podcasts)',
                        self.folder_child_count,
                        {"count": self.folder_child_count}))
            else:
                label_parts.append(ngettext(
                        '%(count)d Playlist Folder Selected',
                        '%(count)d Playlist Folders Selected',
                        self.folder_count,
                        {"count": self.folder_count}))
                label_parts.append(ngettext(
                        '(contains %(count)d playlist)',
                        '(contains %(count)d playlists)',
                        self.folder_child_count,
                        {"count": self.folder_child_count}))

        if self.child_count > 0 and self.folder_count > 0:
            label_parts.append('')
        if self.child_count > 0:
            if tab_type == 'feed':
                label_parts.append(ngettext(
                        '%(count)d Podcast Selected',
                        '%(count)d Podcasts Selected',
                        self.child_count,
                        {"count": self.child_count}))
            elif tab_type == "site":
                label_parts.append(ngettext(
                        '%(count)d Source Selected',
                        '%(count)d Sources Selected',
                        self.child_count,
                        {"count": self.child_count}))
            else:
                label_parts.append(ngettext(
                        '%(count)d Playlist Selected',
                        '%(count)d Playlists Selected',
                        self.child_count,
                        {"count": self.child_count}))
        return widgetset.Label('\n'.join(label_parts))
开发者ID:bluezone,项目名称:miro,代码行数:50,代码来源:displays.py


示例20: _pack_top

    def _pack_top(self):
        """Pack the top row into the VBox; these components are visible in all
        panels.
        """
        self.vbox.pack_start(widgetutil.align_center(self.toggler, top_pad=10))
        items = len(self.items)
        if items > 1:
            # text1 is included because ngettext requires text1 to have all the
            # same placeholders as text2; it won't be used
            text = ngettext("%(items)d", "%(items)d items selected to edit", items, {"items": items})
            label = widgetset.Label(text)
            label.set_bold(True)
            self.vbox.pack_start(widgetutil.align_center(label, top_pad=10, bottom_pad=3))

            text = _(
                "To change a field for all the selected items, check the "
                "checkbox next to the field you'd like to change."
            )
            label = widgetset.Label(text)
            label.set_size(widgetconst.SIZE_SMALL)
            self.vbox.pack_start(widgetutil.align_center(label, bottom_pad=20))
开发者ID:nerdymcgee,项目名称:miro,代码行数:21,代码来源:itemedit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python httpclient.grab_url函数代码示例发布时间:2022-05-27
下一篇:
Python gtcache._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap