Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(92)

Issue 65: xliff2po & po2xliff should handle context

Unified Diff

File: translate/storage/poxliff.py
Patch Set: A more complete patch, supporting CPO and pypo Created 1 year, 4 months ago
Jump to:
View side by-side-diff with in line comments
Index: translate/storage/poxliff.py
===================================================================
--- translate/storage/poxliff.py	(revision 7897)
+++ translate/storage/poxliff.py	(working copy)
@@ -251,7 +251,34 @@
     def hasplural(self):
         return self.xmlelement.tag == self.namespaced("group")
 
+    def getcontext_message(self):
+        """Returns the message context for this unit, if any.
+        This message context is intended to identify the message that
+        represents the PO msgctxt.
+        See http://bugs.locamotion.org/show_bug.cgi?id=258 for details.
+        """
+        groups = self.getcontextgroups("po-msgctxt")
+        context = ""
+        if groups:
+            # groups = [[(context-type, context_message)]]
+            context = groups[0][0][1]
 
+        return context
+
+    def setcontext_message(self, context):
+        """Sets the message context for this unit.
+        The message context will be set as the message which represents the
+        PO msgctxt in XLIFF.
+        See http://bugs.locamotion.org/show_bug.cgi?id=258 for details.
+        """
+        group_name = "po-msgctxt"
+        if self.getcontext_message():
+            self.delcontextgroup(group_name)
+
+        self.createcontextgroup(group_name, [("x-po-msgctxt", context)],
+                                purpose="match information")
+
+
 class PoXliffFile(xliff.xlifffile, poheader.poheader):
     """a file for the po variant of Xliff files"""
     UnitClass = PoXliffUnit

Powered by Google App Engine
This is Rietveld r159