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

Issue 62: CPO support for previous messages

Unified Diff

File: translate/storage/base.py
Patch Set: Updated accessors, tests and added base.py & test_base.py Created 1 year, 4 months ago
Jump to:
View side by-side-diff with in line comments
« no previous file | translate/storage/cpo.py » ('j')
Index: translate/storage/base.py
===================================================================
--- translate/storage/base.py	(revision 7770)
+++ translate/storage/base.py	(working copy)
@@ -64,9 +64,13 @@
         source code this unit came from.
       - Zero or more I{errors}. Some tools (eg. L{pofilter <filters.pofilter>}) can run checks on
         translations and produce error messages.
+      - Zero or one I{prev_source} string, the old version of the translatable text.
+      - Zero or one I{prev_context} string, the old version of the message context.
 
     @group Source: *source*
     @group Target: *target*
+    @group PrevSource: *PrevSource*
+    @group PrevContext: *PrevContext*
     @group Notes: *note*
     @group Locations: *location*
     @group Errors: *error*
@@ -77,6 +81,8 @@
 
         self.source = source
         self.target = None
+        self.prev_source = None
+        self.prev_context = None
         self.notes = ""
         super(TranslationUnit, self).__init__()
 
@@ -290,6 +296,30 @@
         """This unit in a list."""
         return [self]
 
+    def setprev_source(self, source):
+        """Sets the previous source message for this unit"""
+        self.prev_source = source
+
+    def getprev_source(self):
+        """Gets the previous source message for this unit"""
+        return self.prev_source
+
+    def setprev_context(self, context):
+        """Sets the previous context of this unit"""
+        self.prev_context = context
+
+    def getprev_context(self):
+        """Gets the previous context of this unit"""
+        return self.prev_context
+
+    def set_as_previous(self):
+        """Sets this unit as a previous unit message"""
+        if self.isfuzzy():
+            return
+        self.setprev_context(self.getcontext())
+        self.setprev_source(self.source)
+        self.markfuzzy()
+
     def buildfromunit(cls, unit):
         """Build a native unit from a foreign unit, preserving as much  
         information as possible."""

« no previous file | translate/storage/cpo.py » ('j')

Powered by Google App Engine
This is Rietveld r159