本文整理汇总了Python中plone.app.multilingual.browser.selector.LanguageSelectorViewlet._translations方法的典型用法代码示例。如果您正苦于以下问题:Python LanguageSelectorViewlet._translations方法的具体用法?Python LanguageSelectorViewlet._translations怎么用?Python LanguageSelectorViewlet._translations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.multilingual.browser.selector.LanguageSelectorViewlet
的用法示例。
在下文中一共展示了LanguageSelectorViewlet._translations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: languages
# 需要导入模块: from plone.app.multilingual.browser.selector import LanguageSelectorViewlet [as 别名]
# 或者: from plone.app.multilingual.browser.selector.LanguageSelectorViewlet import _translations [as 别名]
def languages(self):
context = aq_inner(self.context)
ls = LanguageSelector(context, self.request, None, None)
ls.update()
results = ls.languages()
supported_langs = [v['code'] for v in results]
missing = set([str(c) for c in supported_langs])
lsv = LanguageSelectorViewlet(context, self.request, None, None)
translations = lsv._translations(missing)
# We want to see the babel_view
append_path = ('', 'babel_view',)
non_viewable = set()
for data in results:
code = str(data['code'])
data['translated'] = code in translations.keys()
appendtourl = '/'.join(append_path)
if data['translated']:
trans, direct, has_view_permission = translations[code]
if not has_view_permission:
# shortcut if the user cannot see the item
non_viewable.add((data['code']))
continue
data['url'] = trans.absolute_url() + appendtourl
else:
non_viewable.add((data['code']))
# filter out non-viewable items
results = [r for r in results if r['code'] not in non_viewable]
return results