diff --git a/news/303.bugfix b/news/303.bugfix new file mode 100644 index 000000000..ad85419a2 --- /dev/null +++ b/news/303.bugfix @@ -0,0 +1,2 @@ +Get the object to be translated correctly +[erral] diff --git a/src/plone/app/multilingual/browser/javascript/babel_helper.js b/src/plone/app/multilingual/browser/javascript/babel_helper.js index cae87ed9b..4f2867d3a 100644 --- a/src/plone/app/multilingual/browser/javascript/babel_helper.js +++ b/src/plone/app/multilingual/browser/javascript/babel_helper.js @@ -137,11 +137,17 @@ original_field.prepend("
"); original_field.children('.translator-widget').click(function () { var field = $(value).attr("rel"); - // Fetch source of text to translate. + // Fetch source of text to translate. + + // we use the current URL to get the context's UID + var url_parts = document.location.pathname.split('++addtranslation++') + var jsondata = { - 'field': field, - 'lang_source': langSource - }; + 'field': field, + 'lang_source': langSource, + // we use the second part of the url_parts, the uid itself + 'context_uid': url_parts[1] + }; var targetelement = destination_field.find('textarea'); var tiny_editor = destination_field.find("textarea.mce_editable"); if (!targetelement.length) { diff --git a/src/plone/app/multilingual/browser/translate.py b/src/plone/app/multilingual/browser/translate.py index cb702e41c..51cc5184d 100644 --- a/src/plone/app/multilingual/browser/translate.py +++ b/src/plone/app/multilingual/browser/translate.py @@ -2,6 +2,7 @@ from plone.app.multilingual import _ from plone.app.multilingual.interfaces import IMultiLanguageExtraOptionsSchema from plone.app.multilingual.interfaces import ITranslationManager +from plone.app.uuid import uuidToObject from plone.base.interfaces import ILanguage from plone.registry.interfaces import IRegistry from plone.uuid.interfaces import IUUID @@ -57,7 +58,17 @@ def __call__(self): ): return _("Need a field") else: - manager = ITranslationManager(self.context) + context_uid = self.request.form.get("context_uid", None) + if context_uid is None: + # try with context if no translation uid is present + manager = ITranslationManager(self.context) + else: + context = uuidToObject(context_uid) + if context is not None: + manager = ITranslationManager(context) + else: + manager = ITranslationManager(self.context) + registry = getUtility(IRegistry) settings = registry.forInterface( IMultiLanguageExtraOptionsSchema, prefix="plone"