plone.restapi/unify-expired-and-excluded-items-handling: Translate titles in @workflow

Carsten Senger <jenkins-z4DKO/[email protected]> Sat, 29 Jul 2017 16:31:32 -0700 (PDT)
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.restapi
Branch: refs/heads/unify-expired-and-excluded-items-handling
Date: 2017-07-26T08:50:44+02:00
Author: Carsten Senger (csenger) <[email protected]>
Commit: https://github.com/plone/plone.restapi/commit/fb081f8bfa2ebe7f1bf2b5d8d26dba2ce19f238c

Translate titles in @workflow

Files changed:
M CHANGES.rst
M src/plone/restapi/services/workflow/info.py
M src/plone/restapi/services/workflow/transition.py

diff --git a/CHANGES.rst b/CHANGES.rst
index f84f297b..c31345f9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,10 @@
 Changelog
 =========
 
+- Translate titles in @workflow
+  [csenger]
+
+
 1.0a20 (2017-07-24)
 -------------------
 
diff --git a/src/plone/restapi/services/workflow/info.py b/src/plone/restapi/services/workflow/info.py
index 729de85d..5dfcf646 100644
--- a/src/plone/restapi/services/workflow/info.py
+++ b/src/plone/restapi/services/workflow/info.py
@@ -20,13 +20,16 @@ def reply(self):
             transitions.append({
                 '@id': '{}/@workflow/{}'.format(
                     self.context.absolute_url(), action['id']),
-                'title': action['title'],
+                'title': self.context.translate(action['title']),
             })
 
+        from pprint import pprint
+        pprint(history)
         for item, action in enumerate(history):
-            history[item]['title'] = wftool.getTitleForStateOnType(
-                action['review_state'],
-                self.context.portal_type)
+            history[item]['title'] = self.context.translate(
+                wftool.getTitleForStateOnType(
+                    action['review_state'],
+                    self.context.portal_type))
 
         return {
             'history': json_compatible(history),
diff --git a/src/plone/restapi/services/workflow/transition.py b/src/plone/restapi/services/workflow/transition.py
index 8f4fc940..fa8d1910 100644
--- a/src/plone/restapi/services/workflow/transition.py
+++ b/src/plone/restapi/services/workflow/transition.py
@@ -59,4 +59,10 @@ def reply(self):
                 message=translate(e.message, context=self.request)))
 
         history = wftool.getInfoFor(self.context, "review_history")
-        return json_compatible(history[-1])
+        action = history[-1]
+        action['title'] = self.context.translate(
+            wftool.getTitleForStateOnType(
+                action['review_state'],
+                self.context.portal_type))
+
+        return json_compatible(action)



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot