Logo Search packages:      
Sourcecode: zope-linguaplone version File versions

def zope-linguaplone-0.7::I18NBaseObject::I18NBaseObject::addTranslation (   self,
  language,
  args,
  kwargs 
)

Add a translation

Definition at line 60 of file I18NBaseObject.py.

00060                                                        :
        """Add a translation"""
        parent = aq_parent(aq_inner(self))
        if ITranslatable.isImplementedBy(parent):
            parent = parent.getTranslation(language) or parent
        canonical = self.getCanonical()
        id = canonical.getId()
        if not parent.checkIdAvailable(id):
            id = '%s-%s'%(canonical.getId(), language)
        if kwargs.get('language', None) != language:
            kwargs['language'] = language
        kwargs[KWARGS_TRANSLATION_KEY] = canonical
        parent.invokeFactory(self.portal_type, id, *args, **kwargs)
        o = getattr(parent, id)
        # If there is a custom factory method that doesn't add the
        # translation relationship, make sure it is done now.
        if o.getCanonical() != self:
            o.addReference(canonical, RELATIONSHIP)
        self.invalidateTranslationCache()
        # If this is a folder, move translated subobjects aswell.
        if self.isPrincipiaFolderish:
            moveids = []
            for obj in self.objectValues():
                if ITranslatable.isImplementedBy(obj) and obj.getLanguage() == language:
                    moveids.append(obj.getId())
            if moveids:
                o.manage_pasteObjects(self.manage_cutObjects(moveids))
        o.reindexObject()

    security.declareProtected(ModifyPortalContent, 'removeTranslation')
    def removeTranslation(self, language):


Generated by  Doxygen 1.6.0   Back to index