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


Python ITranslationManager.has_translation方法代码示例

本文整理汇总了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)
开发者ID:UPCnet,项目名称:genweb.core,代码行数:14,代码来源:utils.py

示例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
开发者ID:fredvd,项目名称:plone.app.multilingual,代码行数:17,代码来源:factory.py

示例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
开发者ID:plone,项目名称:plone.app.multilingual,代码行数:24,代码来源:setup.py

示例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'))
开发者ID:jianaijun,项目名称:plone.app.multilingual,代码行数:6,代码来源:test_api.py


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