From: Ramon N. B. <svn...@pl...> - 2012-09-30 11:46:51
|
Repository: plone.multilingual Branch: refs/heads/master Date: 2012-09-30T04:46:32-07:00 Author: Ramon Navarro Bosch (bloodbare) <ram...@gm...> Commit: https://github.com/plone/plone.multilingual/commit/94582473e4c300832774b000a4960cc4c5b0d8b7 Add the needed code to assure the language is maintained as neutral on shared folder Files changed: M src/plone/multilingual/subscriber.py diff --git a/src/plone/multilingual/subscriber.py b/src/plone/multilingual/subscriber.py index fea971f..93b3aeb 100644 --- a/src/plone/multilingual/subscriber.py +++ b/src/plone/multilingual/subscriber.py @@ -1,5 +1,9 @@ -from plone.multilingual.interfaces import ILanguage, ITranslationManager - +from Acquisition import aq_parent +from Products.CMFPlone.interfaces import IPloneSiteRoot +from plone.multilingual.interfaces import ( + LANGUAGE_INDEPENDENT, + ITranslationManager, + ILanguage) # unregister the translation before the object will be removed def remove_translation_on_delete(obj, event): @@ -7,6 +11,11 @@ def remove_translation_on_delete(obj, event): ITranslationManager(obj).remove_translation(language) -# update the translation on Modified (because the language could be modified) +# check if the parent folder is neutral and assigns neutral language to the content object +# In case is a normal content update translation manager with the new language def update_on_modify(obj, event): + parent = aq_parent(obj) + if (not IPloneSiteRoot.providedBy(parent)) and ILanguage(parent).get_language() == LANGUAGE_INDEPENDENT: + ILanguage(obj).set_language(LANGUAGE_INDEPENDENT) + obj.reindexObject() ITranslationManager(obj).update() |