[open-ils-commits] r11495 - branches/rel_1_4/build/i18n/scripts
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 10 11:21:29 EST 2008
Author: dbs
Date: 2008-12-10 11:21:27 -0500 (Wed, 10 Dec 2008)
New Revision: 11495
Modified:
branches/rel_1_4/build/i18n/scripts/db-seed-i18n.py
Log:
Backport r11104 from trunk to make parsing more robust;
we don't have colon-delimited values in rel_1_4 yet but might as well hedge our bets
Modified: branches/rel_1_4/build/i18n/scripts/db-seed-i18n.py
===================================================================
--- branches/rel_1_4/build/i18n/scripts/db-seed-i18n.py 2008-12-10 04:43:18 UTC (rev 11494)
+++ branches/rel_1_4/build/i18n/scripts/db-seed-i18n.py 2008-12-10 16:21:27 UTC (rev 11495)
@@ -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