[Product-Developers] [Plone-i18n] side-by-side translation view in a working copy?

Daniel Holth dholth at gmail.com
Thu May 12 15:21:03 UTC 2011


Here's my solution so far. I've added a side-by-side edit view called
translate_iter.cpt by adding a getOriginalCopy() for working copies of
I18NBaseObject. By appending /translate_iter instead of /edit to the URL,
the working copy is edited next to the canonical translation of its
original.

I may just add a new 'side-by-side' tab instead of trying to do my own /edit
override...

Does this look like something that could go into LinguaPlone?

Index: I18NBaseObject.py
===================================================================
--- I18NBaseObject.py   (revision 49329)
+++ I18NBaseObject.py   (working copy)
@@ -19,6 +19,9 @@
 from Products.CMFDynamicViewFTI.interface import ISelectableBrowserDefault
 from Products.ZCatalog.Lazy import LazyMap

+from plone.app.iterate.relation import WorkingCopyRelation
+from plone.app.iterate.interfaces import IWorkingCopy
+
 from Products.LinguaPlone import config
 from Products.LinguaPlone import events
 from Products.LinguaPlone import permissions
@@ -261,6 +264,13 @@
             ret = self._getReferenceObject(uid=refs[0].targetUID)
         return ret

+    security.declareProtected(permissions.View, 'getOriginalCopy')
+    def getOriginalCopy(self):
+        """Return the original copy, or self if this is not a working
copy."""
+        if IWorkingCopy.providedBy(self):
+            return self.getReferences(WorkingCopyRelation.relationship)[0]
+        return self
+
     security.declareProtected(permissions.View, 'getLanguage')
     def getLanguage(self):
         """Returns the language code."""


diff translate_item.cpt translate_iter.cpt:

31c31,32
<                    other python:here.getCanonical();
---
>                    original python:here.getOriginalCopy();
>                    other python:original.getCanonical();
114c115
<
tal:define="lp_translating_from request/lp_translating_from |
here/getCanonicalLanguage">
---
>
tal:define="lp_translating_from request/lp_translating_from |
original/getCanonicalLanguage">
116c117
<                                                     tal:define="code
here/getCanonicalLanguage"
---
>                                                     tal:define="code
original/getCanonicalLanguage"


translate_iter.cpt.metadata:

[daniel at exacnet LinguaPlone]$ cat translate_iter.cpt.metadata
[default]
title = Edit

[validators]
validators = validate_atct

[actions]
action.success = traverse_to:string:content_edit
action.success..cancel = traverse_to:string:go_back
action.failure = traverse_to_action:string:edit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110512/04536b62/attachment-0001.html>


More information about the Product-Developers mailing list