本文整理汇总了Python中plone.multilingual.interfaces.ITranslationManager.update方法的典型用法代码示例。如果您正苦于以下问题:Python ITranslationManager.update方法的具体用法?Python ITranslationManager.update怎么用?Python ITranslationManager.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.multilingual.interfaces.ITranslationManager
的用法示例。
在下文中一共展示了ITranslationManager.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_duplicate_translations_are_discarded_when_linking
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import update [as 别名]
def test_duplicate_translations_are_discarded_when_linking(self):
folder_uhoh = create(Builder('folder').titled('uhoh'))
self.items = self.items[:2]
self.items.append({
'_path': '/uhoh',
'_canonicalTranslation': False,
'_translationOf': '/de',
'language': 'en',
})
items = self._run_transmogrifier()
self.assertEqual(3, len(items))
uhoh_manager = ITranslationManager(folder_uhoh)
manager = ITranslationManager(self.folder_en)
uhoh_manager.update()
manager.update()
self.assertEqual('en', ILanguage(folder_uhoh).get_language())
self.assertEqual(1, len(uhoh_manager.get_translated_languages()))
languages = manager.get_translated_languages()
self.assertEqual(2, len(languages))
self.assertIn('de', languages)
self.assertIn('en', languages)
示例2: __call__
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import update [as 别名]
def __call__(self):
language = self.request.get('language', None)
if language:
context = aq_inner(self.context)
translation_manager = ITranslationManager(context)
if ILanguage(context).get_language() == LANGUAGE_INDEPENDENT:
# XXX : Why we need this ? the subscriber from pm should maintain it
language_tool = getToolByName(context, 'portal_languages')
default_language = language_tool.getDefaultLanguage()
ILanguage(context).set_language(default_language)
translation_manager.update()
context.reindexObject()
new_parent = translation_manager.add_translation_delegated(language)
registry = getUtility(IRegistry)
settings = registry.forInterface(IMultiLanguageExtraOptionsSchema)
sdm = self.context.session_data_manager
session = sdm.getSessionData(create=True)
session.set("tg", translation_manager.tg)
baseUrl = new_parent.absolute_url()
# We set the language and redirect to babel_view or not
if settings.redirect_babel_view:
# Call the ++addtranslation++ adapter to show the babel add form
url = '%s/++addtranslation++%s' % (baseUrl, self.context.portal_type)
return self.request.response.redirect(url)
else:
# We look for the creation url for this content type
# Get the factory
types_tool = getToolByName(self.context, 'portal_types')
# Note: we don't check 'allowed' or 'available' here, because these are
# slow. We assume the 'allowedTypes' list has already performed the
# necessary calculations
actions = types_tool.listActionInfos(
object=new_parent,
check_permissions=False,
check_condition=False,
category='folder/add',
)
addActionsById = dict([(a['id'], a) for a in actions])
typeId = self.context.portal_type
addAction = addActionsById.get(typeId, None)
if addAction is not None:
url = addAction['url']
if not url:
url = '%s/createObject?type_name=%s' % (baseUrl, quote_plus(typeId))
return self.request.response.redirect(url)
示例3: handle_create
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import update [as 别名]
def handle_create(self, action):
data, errors = self.extractData()
if not errors:
language = data['language']
translation_manager = ITranslationManager(aq_inner(self.context))
if ILanguage(self.context).get_language() == LANGUAGE_INDEPENDENT:
language_tool = getToolByName(self.context, 'portal_languages')
default_language = language_tool.getDefaultLanguage()
ILanguage(self.context).set_language(default_language)
translation_manager.update()
self.context.reindexObject(idxs='language')
translation_manager.add_translation(language)
translated = translation_manager.get_translation(language)
return self.request.response.redirect(translated.absolute_url() \
+ '/edit')
示例4: handle_create
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import update [as 别名]
def handle_create(self, action):
data, errors = self.extractData()
if not errors:
language = data['language']
translation_manager = ITranslationManager(aq_inner(self.context))
if ILanguage(self.context).get_language() == LANGUAGE_INDEPENDENT:
language_tool = getToolByName(self.context, 'portal_languages')
default_language = language_tool.getDefaultLanguage()
ILanguage(self.context).set_language(default_language)
translation_manager.update()
self.context.reindexObject(idxs='language')
translation_manager.add_translation(language)
translated = translation_manager.get_translation(language)
registry = getUtility(IRegistry)
settings = registry.forInterface(IMultiLanguageExtraOptionsSchema)
if settings.redirect_babel_view:
return self.request.response.redirect(
translated.absolute_url() + '/babel_edit?set_language=%s' % language)
else:
return self.request.response.redirect(
translated.absolute_url() + '/edit?set_language=%s' %
language)