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


Python ITranslationManager.register_translation方法代码示例

本文整理汇总了Python中plone.multilingual.interfaces.ITranslationManager.register_translation方法的典型用法代码示例。如果您正苦于以下问题:Python ITranslationManager.register_translation方法的具体用法?Python ITranslationManager.register_translation怎么用?Python ITranslationManager.register_translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.multilingual.interfaces.ITranslationManager的用法示例。


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

示例1: __call__

# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import register_translation [as 别名]
    def __call__(self):
        pc = getToolByName(self.context, "portal_catalog")
        pl = getToolByName(self.context, "portal_languages")
        self.results = []
        for language_supported in pl.getSupportedLanguages():
            translated_objects = pc.searchResults(object_provides=LP_TRANSLATABLE, Language=language_supported)
            for brain in translated_objects:
                obj = brain.getObject()
                if obj.isCanonical():
                    translations = obj.getTranslations(include_canonical=False)
                    manager = ITranslationManager(obj)
                    if translations:
                        for language in translations.keys():
                            try:
                                manager.register_translation(language, translations[language][0])
                            except KeyError:
                                logger.warning(
                                    "%s already translated to %s: %s"
                                    % (obj.id, language, str(manager.get_translations()))
                                )

                        self.results.append(str(manager.get_translations()))

        logger.info("Finished with transferring catalog information")
        return self.template()
开发者ID:pysailor,项目名称:plone.app.multilingual,代码行数:27,代码来源:migrator.py

示例2: linkTranslations

# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import register_translation [as 别名]
 def linkTranslations(self):
     """
     Links the translations of the default language Folders
     """
     doneSomething = False
     canonical = ITranslationManager(self.folders[self.defaultLanguage])
     for language in self.languages:
         if ((language != self.defaultLanguage) and (not
             canonical.has_translation(language))):
             canonical.register_translation(language,
                                            self.folders[language])
             doneSomething = True
     if doneSomething:
         LOG.info("Translations linked.")
     return doneSomething
开发者ID:adam139,项目名称:plone.app.multilingual,代码行数:17,代码来源:setup.py

示例3: update

# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import register_translation [as 别名]
    def update(self, obj, data):
        ILanguage(obj).set_language(data['language'])
        IMutableTG(obj).set(data['translation_group_uuid'])

        manager = ITranslationManager(obj)
        manager.register_translation(data['language'], obj)
开发者ID:maikroeder,项目名称:ftw.inflator,代码行数:8,代码来源:multilingual.py


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