def multilingualMoveObject(content, language):
    """
    Move content object and its contained objects to a new language folder
    Also set the language on all the content moved
    """
    if is_shared(content):
        # In case is shared we are going to create it on the language root
        # folder

        orig_content = get_original_object(content)
        target_folder = getattr(getSite(), language)
        # It's going to be a non shared content so we remove it from
        # portal_catalog

    else:
        orig_content = content
        target_folder = ITranslationLocator(orig_content)(language)

    parent = aq_parent(orig_content)
    cb_copy_data = parent.manage_cutObjects(orig_content.getId())
    list_ids = target_folder.manage_pasteObjects(cb_copy_data)
    new_id = list_ids[0]['new_id']
    new_object = target_folder[new_id]

    if hasattr(new_object, '_v_is_shared_content'):
        new_object._v_is_shared_content = False
    new_object.reindexObject()

    return new_object
    def test_locator(self):
        folder_ca = createContentInContainer(self.portal['ca'],
                                             'Folder',
                                             title=u"Test folder")
        subfolder_ca = createContentInContainer(
            self.portal['ca']['test-folder'], 'Folder', title=u"Test folder")

        locator = ITranslationLocator(subfolder_ca)
        self.assertEqual(locator('es'), self.portal['es'])

        ITranslationManager(folder_ca).add_translation('es')
        folder_es = ITranslationManager(folder_ca).get_translation('es')

        child_locator = ITranslationLocator(subfolder_ca)
        self.assertEqual(child_locator('es'), folder_es)
Example #3
0
    def reply(self):
        target_language = self.request.form["target_language"]

        locator = ITranslationLocator(self.context)
        parent = locator(target_language)

        return {"@id": parent.absolute_url()}
Example #4
0
def multilingualMoveObject(content, language):
    """Move content object and its contained objects to a new language folder
    Also set the language on all the content moved

    """
    if is_language_independent(content):
        # Language independent content will be created into language roo
        target_folder = getattr(getSite(), language)
    else:
        target_folder = ITranslationLocator(content)(language)

    parent = aq_parent(content)

    copy_data = parent.manage_cutObjects(content.getId())
    list_ids = target_folder.manage_pasteObjects(copy_data)
    new_id = list_ids[0]['new_id']
    new_object = target_folder[new_id]

    new_object.reindexObject()

    return new_object
Example #5
0
 def add_translation_delegated(self, language):
     """
     Creation is delegated to factory/++add++
     Lets return the url where we are going to create the translation
     """
     if not language and language != '':
         raise KeyError('There is no target language')
     # event
     notify(ObjectWillBeTranslatedEvent(self.context, language))
     # localize where we need to store the new object
     locator = ITranslationLocator(self.context)
     parent = locator(language)
     return parent
Example #6
0
 def __call__(self, language):
     content_type = self.context.portal_type
     # parent for translation
     locator = ITranslationLocator(self.context)
     parent = locator(language)
     # id for translation
     name_chooser = ITranslationIdChooser(self.context)
     content_id = name_chooser(parent, language)
     # creating the translation
     new_id = parent.invokeFactory(type_name=content_type,
                                   id=content_id,
                                   language=language)
     new_content = getattr(parent, new_id)
     # clone language-independent content
     cloner = ITranslationCloner(self.context)
     cloner(new_content)
     return new_content