[Python-checkins] python/dist/src/Lib gettext.py,1.18,1.19
bwarsaw@users.sourceforge.net
bwarsaw@users.sourceforge.net
Fri, 11 Apr 2003 13:26:49 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv8084
Modified Files:
gettext.py
Log Message:
NullTranslations.__init__(): Back out of setting the default charset
to iso-8859-1.
GNUTranslations._parse(): Back out the addition of a test for
Project-ID-Version in the metadata. This was deliberately removed in
response to SF patch #700839.
Also, re-organize the code in _parse() so we parse the metadata header
containing the charset parameter before we try to decode any strings
using charset.
Index: gettext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gettext.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** gettext.py 11 Apr 2003 18:36:04 -0000 1.18
--- gettext.py 11 Apr 2003 20:26:47 -0000 1.19
***************
*** 173,177 ****
def __init__(self, fp=None):
self._info = {}
! self._charset = 'iso-8859-1'
self._fallback = None
if fp is not None:
--- 173,177 ----
def __init__(self, fp=None):
self._info = {}
! self._charset = None
self._fallback = None
if fp is not None:
***************
*** 265,286 ****
msg = buf[moff:mend]
tmsg = buf[toff:tend]
- if msg.find('\x00') >= 0:
- # Plural forms
- msgid1, msgid2 = msg.split('\x00')
- tmsg = tmsg.split('\x00')
- if self._coerce:
- msgid1 = unicode(msgid1, self._charset)
- tmsg = [unicode(x, self._charset) for x in tmsg]
- for i in range(len(tmsg)):
- catalog[(msgid1, i)] = tmsg[i]
- else:
- if self._coerce:
- msg = unicode(msg, self._charset)
- tmsg = unicode(tmsg, self._charset)
- catalog[msg] = tmsg
else:
raise IOError(0, 'File is corrupt', filename)
# See if we're looking at GNU .mo conventions for metadata
! if mlen == 0 and tmsg.lower().startswith('project-id-version:'):
# Catalog description
for item in tmsg.splitlines():
--- 265,272 ----
msg = buf[moff:mend]
tmsg = buf[toff:tend]
else:
raise IOError(0, 'File is corrupt', filename)
# See if we're looking at GNU .mo conventions for metadata
! if mlen == 0:
# Catalog description
for item in tmsg.splitlines():
***************
*** 300,303 ****
--- 286,303 ----
plural = v[1].split('plural=')[1]
self.plural = c2py(plural)
+ if msg.find('\x00') >= 0:
+ # Plural forms
+ msgid1, msgid2 = msg.split('\x00')
+ tmsg = tmsg.split('\x00')
+ if self._coerce:
+ msgid1 = unicode(msgid1, self._charset)
+ tmsg = [unicode(x, self._charset) for x in tmsg]
+ for i in range(len(tmsg)):
+ catalog[(msgid1, i)] = tmsg[i]
+ else:
+ if self._coerce:
+ msg = unicode(msg, self._charset)
+ tmsg = unicode(tmsg, self._charset)
+ catalog[msg] = tmsg
# advance to next entry in the seek tables
masteridx += 8