本文整理汇总了Python中plone.app.multilingual.interfaces.ITranslationManager.has_translation方法的典型用法代码示例。如果您正苦于以下问题:Python ITranslationManager.has_translation方法的具体用法?Python ITranslationManager.has_translation怎么用?Python ITranslationManager.has_translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.multilingual.interfaces.ITranslationManager
的用法示例。
在下文中一共展示了ITranslationManager.has_translation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: link_translations
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import has_translation [as 别名]
def link_translations(items):
"""
Links the translations with the declared items with the form:
[(obj1, lang1), (obj2, lang2), ...] assuming that the first element
is the 'canonical' (in PAM there is no such thing).
"""
# Grab the first item object and get its canonical handler
canonical = ITranslationManager(items[0][0])
for obj, language in items:
if not canonical.has_translation(language):
canonical.register_translation(language, obj)
示例2: __call__
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import has_translation [as 别名]
def __call__(self, language):
"""
Look for the closest translated folder or siteroot
"""
parent = aq_parent(self.context)
translated_parent = parent
found = False
while not (IPloneSiteRoot.providedBy(parent) and not ILanguageRootFolder.providedBy(parent)) and not found:
parent_translation = ITranslationManager(parent)
if parent_translation.has_translation(language):
translated_parent = \
parent_translation.get_translation(language)
found = True
parent = aq_parent(parent)
return translated_parent
示例3: linkTranslations
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import has_translation [as 别名]
def linkTranslations(self):
"""Links the translations of the default language Folders
"""
doneSomething = False
try:
canonical = ITranslationManager(self.folders[self.defaultLanguage])
except TypeError as e:
raise TypeError(str(e) + u' Are your folders ITranslatable?')
for language in self.languages:
if language == self.defaultLanguage:
continue
if not canonical.has_translation(language):
language_folder = self.folders[language]
canonical.register_translation(language, language_folder)
doneSomething = True
if doneSomething:
logger.info(u'Translations linked.')
return doneSomething
示例4: test_has_translation
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import has_translation [as 别名]
def test_has_translation(self):
translation_manager = ITranslationManager(self.a_ca)
self.assertTrue(translation_manager.has_translation('ca'))
self.assertFalse(translation_manager.has_translation('es'))