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
1548
1548
Tools/Demos
1549
1549
-----------
1550
1550
1551
+ - Issue #5464: Implement plural forms in msgfmt.py.
1552
+
1551
1553
- iobench (a file I/O benchmark) and ccbench (a concurrency benchmark) were
1552
1554
added to the `Tools/` directory. They were previously living in the
1553
1555
sandbox.
Original file line number Diff line number Diff line change @@ -132,16 +132,39 @@ def make(filename, outfile):
132
132
if l [0 ] == '#' :
133
133
continue
134
134
# 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' ) :
136
136
if section == STR :
137
137
add (msgid , msgstr , fuzzy )
138
138
section = ID
139
139
l = l [5 :]
140
140
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
141
151
# Now we are in a msgstr section
142
152
elif l .startswith ('msgstr' ):
143
153
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 :]
145
168
# Skip empty lines
146
169
l = l .strip ()
147
170
if not l :
You can’t perform that action at this time.
0 commit comments