def addTranslation(self, language, *args, **kwargs):
    """Adds a translation."""
    if self.hasTranslation(language):
        translation = self.getTranslation(language)
        raise AlreadyTranslated(translation.absolute_url())

    locator = ILocateTranslation(self)
    parent = locator.findLocationForTranslation(language)

    notify(events.ObjectWillBeTranslatedEvent(self, language))

    canonical = self.getCanonical()
    kwargs[config.KWARGS_TRANSLATION_KEY] = canonical

    factory = ITranslationFactory(self)
    translation = factory.createTranslation(
        parent, language, *args, **kwargs)
    # special handling for Belgium
    ppath = '/'.join(parent.getPhysicalPath())
    if not ppath.startswith('/osha/portal/fop/belgium'):
        translation.unmarkCreationFlag()
    translation.reindexObject()
    notify(events.ObjectTranslatedEvent(self, translation, language))

    return translation
    def addTranslation(self, language, *args, **kwargs):
        """Adds a translation."""
        if self.hasTranslation(language):
            translation = self.getTranslation(language)
            raise AlreadyTranslated(translation.absolute_url())

        locator = ILocateTranslation(self)
        parent = locator.findLocationForTranslation(language)

        notify(events.ObjectWillBeTranslatedEvent(self, language))

        canonical = self.getCanonical()
        kwargs[config.KWARGS_TRANSLATION_KEY] = canonical

        factory = ITranslationFactory(self)
        translation = factory.createTranslation(
            parent, language, *args, **kwargs)
        translation.reindexObject()
        notify(events.ObjectTranslatedEvent(self, translation, language))

        return translation
    def addTranslation(self, language, *args, **kwargs):
        """Adds a translation."""
        if self.hasTranslation(language):
            translation = self.getTranslation(language)
            raise AlreadyTranslated(translation.absolute_url())

        locator = ILocateTranslation(self)
        parent = locator.findLocationForTranslation(language)

        notify(events.ObjectWillBeTranslatedEvent(self, language))

        canonical = self.getCanonical()
        kwargs[config.KWARGS_TRANSLATION_KEY] = canonical

        factory = ITranslationFactory(self)
        translation = factory.createTranslation(parent, language, *args,
                                                **kwargs)
        translation.reindexObject()
        notify(events.ObjectTranslatedEvent(self, translation, language))

        return translation
Exemple #4
0
def addTranslation(self, language, *args, **kwargs):
    """Adds a translation."""
    if self.hasTranslation(language):
        translation = self.getTranslation(language)
        raise AlreadyTranslated(translation.absolute_url())

    locator = ILocateTranslation(self)
    parent = locator.findLocationForTranslation(language)

    notify(events.ObjectWillBeTranslatedEvent(self, language))

    canonical = self.getCanonical()
    kwargs[config.KWARGS_TRANSLATION_KEY] = canonical

    factory = ITranslationFactory(self)
    translation = factory.createTranslation(parent, language, *args, **kwargs)
    # special handling for Belgium
    ppath = '/'.join(parent.getPhysicalPath())
    if not ppath.startswith('/osha/portal/fop/belgium'):
        translation.unmarkCreationFlag()
    translation.reindexObject()
    notify(events.ObjectTranslatedEvent(self, translation, language))

    return translation
Exemple #5
0
    def test_version_prefixed_translated_content(self):
        """ Test the version id of a translation contains the same version id
            as the object it derived from plus language id
        """
        if not has_lingua_plone:
            assert True
            return
        pvtool = getToolByName(self.portal, 'portal_eea_versions')
        vobjs = PortalType(id='LNK')
        vobjs.title = 'LNK'
        vobjs.search_type = 'Link'
        pvtool[vobjs.getId()] = vobjs
        link_id = self.folder.invokeFactory("Link", 'l1')
        link = self.folder[link_id]
        ITranslationFactory(self.folder)

        trans_lang = str(link.languages()[-1])
        translation = link.addTranslation(trans_lang)
        assert IVersionControl(translation).versionId == 'LNK-1-' + trans_lang