本文整理汇总了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()
示例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
示例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)