Changeset 391 for python/trunk/Tools/i18n/msgfmt.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Tools/i18n/msgfmt.py
r2 r391 26 26 """ 27 27 28 import os 28 29 import sys 29 import os30 import ast 30 31 import getopt 31 32 import struct … … 138 139 continue 139 140 # Now we are in a msgid section, output previous section 140 if l.startswith('msgid') :141 if l.startswith('msgid') and not l.startswith('msgid_plural'): 141 142 if section == STR: 142 143 add(msgid, msgstr, fuzzy) … … 144 145 l = l[5:] 145 146 msgid = msgstr = '' 147 is_plural = False 148 # This is a message with plural forms 149 elif l.startswith('msgid_plural'): 150 if section != ID: 151 print >> sys.stderr, 'msgid_plural not preceded by msgid on %s:%d' %\ 152 (infile, lno) 153 sys.exit(1) 154 l = l[12:] 155 msgid += '\0' # separator of singular and plural 156 is_plural = True 146 157 # Now we are in a msgstr section 147 158 elif l.startswith('msgstr'): 148 159 section = STR 149 l = l[6:] 160 if l.startswith('msgstr['): 161 if not is_plural: 162 print >> sys.stderr, 'plural without msgid_plural on %s:%d' %\ 163 (infile, lno) 164 sys.exit(1) 165 l = l.split(']', 1)[1] 166 if msgstr: 167 msgstr += '\0' # Separator of the various plural forms 168 else: 169 if is_plural: 170 print >> sys.stderr, 'indexed msgstr required for plural on %s:%d' %\ 171 (infile, lno) 172 sys.exit(1) 173 l = l[6:] 150 174 # Skip empty lines 151 175 l = l.strip() 152 176 if not l: 153 177 continue 154 # XXX: Does this always follow Python escape semantics? 155 l = eval(l) 178 l = ast.literal_eval(l) 156 179 if section == ID: 157 180 msgid += l
Note:
See TracChangeset
for help on using the changeset viewer.