[open-ils-commits] r11404 - trunk/build/i18n/scripts

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 4 13:13:57 EST 2008


Author: dbs
Date: 2008-12-04 13:13:54 -0500 (Thu, 04 Dec 2008)
New Revision: 11404

Modified:
   trunk/build/i18n/scripts/db-seed-i18n.py
Log:
Hack to work around occurrence IDs containing colons (which confuse upstream polib)


Modified: trunk/build/i18n/scripts/db-seed-i18n.py
===================================================================
--- trunk/build/i18n/scripts/db-seed-i18n.py	2008-12-04 05:48:41 UTC (rev 11403)
+++ trunk/build/i18n/scripts/db-seed-i18n.py	2008-12-04 18:13:54 UTC (rev 11404)
@@ -74,11 +74,16 @@
                     fq_field = "%s.%s" % (fi18n.group('class'), fi18n.group('property'))
                     # Unescape escaped SQL single-quotes for translators' sanity
                     msgid = re.compile(r'\'\'').sub("'", fi18n.group('string'))
+
+                    # Hmm, sometimes people use ":" in text identifiers and
+                    # polib doesn't seem to like that; urlencode the colon
+                    occurid = re.compile(r':').sub("%3A", fi18n.group('id'))
+
                     if (msgid in serts):
-                        serts[msgid].occurrences.append((fq_field, fi18n.group('id')))
+                        serts[msgid].occurrences.append((fq_field, occurid))
                     else:
                         poe = polib.POEntry()
-                        poe.occurrences = [(fq_field, fi18n.group('id'))]
+                        poe.occurrences = [(fq_field, occurid)]
                         poe.msgid = msgid
                         serts[msgid] = poe
             except:
@@ -99,10 +104,14 @@
             for fq_field in entry.occurrences:
                 # Escape SQL single-quotes to avoid b0rkage
                 msgstr = re.compile(r'\'').sub("''", entry.msgstr)
+
+                # And unescape any colons in the occurence ID
+                occurid = re.compile(r'%3A').sub(':', fq_field[1])
+
                 if msgstr == '':
                     # Don't generate a stmt for an untranslated string
                     break
-                self.sql.append(insert % (fq_field[0], fq_field[1], locale, msgstr))
+                self.sql.append(insert % (fq_field[0], occurid, locale, msgstr))
 
 def main():
     """



More information about the open-ils-commits mailing list