i18n/posplit
changeset 20359 ff6ab0b2ebf7
parent 11389 4fd49329a1b5
child 20361 3fe079d3a2b4
--- a/i18n/posplit	Sun Nov 17 20:16:14 2013 +0100
+++ b/i18n/posplit	Mon Feb 03 21:31:35 2014 +0100
@@ -5,6 +5,7 @@
 # license: MIT/X11/Expat
 #
 
+import re
 import sys
 import polib
 
@@ -30,6 +31,7 @@
     cache = {}
     entries = po[:]
     po[:] = []
+    findd = re.compile(r' *\.\. (\w+)::') # for finding directives
     for entry in entries:
         msgids = entry.msgid.split(u'\n\n')
         if entry.msgstr:
@@ -51,6 +53,14 @@
         for msgid, msgstr in zip(msgids, msgstrs):
             if msgid:
                 newentry = mkentry(entry, delta, msgid, msgstr)
+                mdirective = findd.match(msgid)
+                if mdirective:
+                    directive = mdirective.group(1)
+                    comment = 'do not translate: .. %s::' % directive
+                    if not newentry.comment:
+                        newentry.comment = comment
+                    elif comment not in newentry.comment:
+                        newentry.comment += '\n' + comment
                 addentry(po, newentry, cache)
             delta += 2 + msgid.count('\n')
     po.save()