summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2010-06-04 18:04:42 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2010-06-04 18:04:42 (GMT)
commit5aafc17405127b728c66b2e7e516c1c9c4d660cb (patch)
tree0c364a01ca0d31e39b661bb9c799a3c9e0f7f38c /Tools
parent26eec5877017f805dbc4edd3f82df6ddd54b9315 (diff)
downloadcpython-5aafc17405127b728c66b2e7e516c1c9c4d660cb.zip
cpython-5aafc17405127b728c66b2e7e516c1c9c4d660cb.tar.gz
cpython-5aafc17405127b728c66b2e7e516c1c9c4d660cb.tar.bz2
Issue #5464: Implement plural forms in msgfmt.py.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/i18n/msgfmt.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py
index 6433131..5dd5430 100755
--- a/Tools/i18n/msgfmt.py
+++ b/Tools/i18n/msgfmt.py
@@ -133,16 +133,39 @@ def make(filename, outfile):
if l[0] == '#':
continue
# Now we are in a msgid section, output previous section
- if l.startswith('msgid'):
+ if l.startswith('msgid') and not l.startswith('msgid_plural'):
if section == STR:
add(msgid, msgstr, fuzzy)
section = ID
l = l[5:]
msgid = msgstr = ''
+ is_plural = False
+ # This is a message with plural forms
+ elif l.startswith('msgid_plural'):
+ if section != ID:
+ print >> sys.stderr, 'msgid_plural not preceeded by msgid on %s:%d' %\
+ (infile, lno)
+ sys.exit(1)
+ l = l[12:]
+ msgid += '\0' # separator of singular and plural
+ is_plural = True
# Now we are in a msgstr section
elif l.startswith('msgstr'):
section = STR
- l = l[6:]
+ if l.startswith('msgstr['):
+ if not is_plural:
+ print >> sys.stderr, 'plural without msgid_plural on %s:%d' %\
+ (infile, lno)
+ sys.exit(1)
+ l = l.split(']', 1)[1]
+ if msgstr:
+ msgstr += '\0' # Separator of the various plural forms
+ else:
+ if is_plural:
+ print >> sys.stderr, 'indexed msgstr required for plural on %s:%d' %\
+ (infile, lno)
+ sys.exit(1)
+ l = l[6:]
# Skip empty lines
l = l.strip()
if not l: