diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2010-06-04 18:14:42 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2010-06-04 18:14:42 (GMT) |
commit | cb081b838f750a6ea73ef2caf58631e5ed843030 (patch) | |
tree | ed37e8b057dedcf55e84373087e2343aae0f3f0c /Tools | |
parent | 0b99883547ecf03aad0eff7f2fd4a484215b1c52 (diff) | |
download | cpython-cb081b838f750a6ea73ef2caf58631e5ed843030.zip cpython-cb081b838f750a6ea73ef2caf58631e5ed843030.tar.gz cpython-cb081b838f750a6ea73ef2caf58631e5ed843030.tar.bz2 |
Merged revisions 81697 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81697 | martin.v.loewis | 2010-06-04 20:04:42 +0200 (Fr, 04 Jun 2010) | 2 lines
Issue #5464: Implement plural forms in msgfmt.py.
........
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/i18n/msgfmt.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index f481c88..6239f8b 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -132,16 +132,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('msgid_plural not preceeded by msgid on %s:%d' % (infile, lno), + file=sys.stderr) + 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), + file=sys.stderr) + 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), + file=sys.stderr) + sys.exit(1) + l = l[6:] # Skip empty lines l = l.strip() if not l: |