Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.4, 2.0.5, and 2.1

stable i18n: add support for plural forms in msgfmt

This is a merge of differences between Python 2.3 and 2.7 into msgfmt.py
(that was originally based on Python 2.3 script)

Changeset 9f9c5eb5cd35

Parent 11b9a0468d8f

by Andrei Polushin

Changes to one file · Browse files at 9f9c5eb5cd35 Showing diff from parent 11b9a0468d8f Diff from another changeset...

Change 1 of 1 Show Entire File i18n/​msgfmt.py Stacked
 
164
165
166
167
 
 
 
168
169
170
 
 
 
 
 
 
 
 
 
 
171
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176
177
 
164
165
166
 
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
@@ -164,14 +164,39 @@
  l = l[7:]   msgctxt = ''   # Now we are in a msgid section, output previous section - elif l.startswith('msgid'): + elif 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: