File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1548,6 +1548,8 @@ Tests
15481548Tools/Demos
15491549-----------
15501550
1551+ - Issue #5464: Implement plural forms in msgfmt.py.
1552+
15511553- iobench (a file I/O benchmark) and ccbench (a concurrency benchmark) were
15521554 added to the `Tools/` directory. They were previously living in the
15531555 sandbox.
Original file line number Diff line number Diff line change @@ -132,16 +132,39 @@ def make(filename, outfile):
132132 if l [0 ] == '#' :
133133 continue
134134 # Now we are in a msgid section, output previous section
135- if l .startswith ('msgid' ):
135+ if l .startswith ('msgid' ) and not l . startswith ( 'msgid_plural' ) :
136136 if section == STR :
137137 add (msgid , msgstr , fuzzy )
138138 section = ID
139139 l = l [5 :]
140140 msgid = msgstr = ''
141+ is_plural = False
142+ # This is a message with plural forms
143+ elif l .startswith ('msgid_plural' ):
144+ if section != ID :
145+ print ('msgid_plural not preceeded by msgid on %s:%d' % (infile , lno ),
146+ file = sys .stderr )
147+ sys .exit (1 )
148+ l = l [12 :]
149+ msgid += '\0 ' # separator of singular and plural
150+ is_plural = True
141151 # Now we are in a msgstr section
142152 elif l .startswith ('msgstr' ):
143153 section = STR
144- l = l [6 :]
154+ if l .startswith ('msgstr[' ):
155+ if not is_plural :
156+ print (sys .stderr , 'plural without msgid_plural on %s:%d' % (infile , lno ),
157+ file = sys .stderr )
158+ sys .exit (1 )
159+ l = l .split (']' , 1 )[1 ]
160+ if msgstr :
161+ msgstr += '\0 ' # Separator of the various plural forms
162+ else :
163+ if is_plural :
164+ print (sys .stderr , 'indexed msgstr required for plural on %s:%d' % (infile , lno ),
165+ file = sys .stderr )
166+ sys .exit (1 )
167+ l = l [6 :]
145168 # Skip empty lines
146169 l = l .strip ()
147170 if not l :
You can’t perform that action at this time.
0 commit comments