Commit Graph

31 Commits

Author SHA1 Message Date
Guido van Rossum 652f446d42 Fixes for str/uni/bytes for gettext.py. test_gettext.py passes.
Fix by Christian Heimes, SF# 1751958, who writes:

  I tested the fixes with the Zope3 zope.app.locales packages.
  The mo files are loaded and parsed w/o any problem.
  The translation with gettext.gettext is working as expected.
2007-07-12 08:04:06 +00:00
Guido van Rossum 68937b4cbc Change some uses of cStringIO.StringIO to io.StringIO.
This is undoubtedly insufficient and in some cases just as broken as before.
2007-05-18 00:51:22 +00:00
Guido van Rossum 805365ee39 Merged revisions 55007-55179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk

........
  r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines

  Use the new print syntax, at least.
........
  r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line

  remove old cruftiness
........
  r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line

  make this work with the new Python
........
  r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line

  Get asdl code gen working with Python 2.3.  Should continue to work with 3.0
........
  r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line

  Verify checkins to p3yk (sic) branch go to 3000 list.
........
  r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line

  Fix this test so it runs again by importing warnings_test properly.
........
  r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines

  So long xrange.  range() now supports values that are outside
  -sys.maxint to sys.maxint.  floats raise a TypeError.

  This has been sitting for a long time.  It probably has some problems and
  needs cleanup.  Objects/rangeobject.c now uses 4-space indents since
  it is almost completely new.
........
  r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines

  Fix two tests that were previously depending on significant spaces
  at the end of a line (and before that on Python 2.x print behavior
  that has no exact equivalent in 3.0).
........
2007-05-07 22:24:25 +00:00
Guido van Rossum ef87d6ed94 Rip out all the u"..." literals and calls to unicode(). 2007-05-02 19:09:54 +00:00
Guido van Rossum e2a383d062 Rip out 'long' and 'L'-suffixed integer literals.
(Rough first cut.)
2007-01-15 16:59:06 +00:00
Georg Brandl 602b9ba6b3 Patch #1349274: gettext.install() now optionally installs additional
translation functions other than _() in the builtin namespace.
2006-02-19 13:26:36 +00:00
Raymond Hettinger a617271dbd Use cStringIO where available. 2004-12-31 19:15:26 +00:00
Gustavo Niemeyer 7bd33c5e22 This change implements the following gettext features, as
discussed recently in python-dev:

In _locale module:

- bind_textdomain_codeset() binding

In gettext module:

- bind_textdomain_codeset() function
- lgettext(), lngettext(), ldgettext(), ldngettext(),
  which return translated strings encoded in
  preferred system encoding, if
  bind_textdomain_codeset() was not used.
- Added equivalent functionality in translate()
  function and catalog classes.

Every change was also documented.
2004-07-22 18:44:01 +00:00
Raymond Hettinger bac788a3cd Replace str.find()!=1 with the more readable "in" operator. 2004-05-04 09:21:43 +00:00
Barry Warsaw b8c787606c GNUTranslations._parse(): Initialize local variable k so that if the
first line of a header section isn't an RFC-ish header, it's just
ignored instead of throwing an UnboundLocalError.

Backport candidate.
2003-10-04 02:28:31 +00:00
Barry Warsaw 7de63f57c8 GNUTranslations._parse(): Fix SF bug #658233, where continuation lines
in .po metadata caused a crash.

Backport candidate.
2003-05-20 17:26:48 +00:00
Barry Warsaw c4acc2bd32 GNUTranslations:
__init__(): Removed since we no longer need the coerce flag.
    Message ids and strings are now always coerced to Unicode, /if/
    the catalog specified a charset parameter.

    gettext(), ngettext(): Since the message strings are Unicodes in
    the catalog, coerce back to encoded 8-bit strings on return.

    ugettext(), ungettext(): Coerce the message ids to Unicode when
    there's no entry for the id in the catalog.

Minor code cleanups; use booleans where appropriate.
2003-04-24 18:13:39 +00:00
Barry Warsaw 6008cbd4c2 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.
2003-04-11 20:26:47 +00:00
Barry Warsaw a1ce93f87c From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
- Expose NullTranslations and GNUTranslations to __all__

- Set the default charset to iso-8859-1.  It used to be None, which
would cause problems with .ugettext() if the file had no charset
parameter.  Arguably, the po/mo file would be broken, but I still think
iso-8859-1 is a reasonable default.

- Add a "coerce" default argument to GNUTranslations's constructor.  The
reason for this is that in Zope, we want all msgids and msgstrs to be
Unicode.  For the latter, we could use .ugettext() but there isn't
currently a mechanism for Unicode-ifying msgids.

The plan then is that the charset parameter specifies the encoding for
both the msgids and msgstrs, and both are decoded to Unicode when read.
For example, we might encode po files with utf-8. I think the GNU
gettext tools don't care.

Since this could potentially break code [*] that wants to use the
encoded interface .gettext(), the constructor flag is added, defaulting
to False.  Most code I suspect will want to set this to True and use
.ugettext().

- A few other minor changes from the Zope project, including asserting
that a zero-length msgid must have a Project-ID-Version header for it to
be counted as the metadata record.
2003-04-11 18:36:43 +00:00
Martin v. Löwis a57dccdcd4 Patch #700839: Fix bugs in the plural handling. 2003-03-10 16:01:43 +00:00
Martin v. Löwis d899605e30 Patch #633547: Support plural forms. Do TODOs in test suite. 2002-11-21 21:45:32 +00:00
Barry Warsaw 09707e3637 Patch by Tim to shut up the compiler's DeprecationWarnings on the
high-bit-set hex constants.
2002-08-14 15:09:12 +00:00
Raymond Hettinger 094662a165 Replace boolean test with is None 2002-06-01 01:29:16 +00:00
Martin v. Löwis a55ffaeee9 Add a per-message fallback mechanism for translations. 2002-01-11 06:58:49 +00:00
Martin v. Löwis 1be6419871 Add fallback argument to translation(). Request fallbacks on install.
Fixes #500595.
2002-01-11 06:33:28 +00:00
Skip Montanaro 2dd4276559 added a few more __all__ lists
fixed typo in ihooks docstring
2001-01-23 15:35:05 +00:00
Tim Peters 07e99cb774 Whitespace normalization. 2001-01-14 23:47:14 +00:00
Barry Warsaw 75f8101c42 find(): Application of (slightly modified) SF patch #101928 by Ulf
Betlehem, verified by Peter Funk.  Fixes preservation of language
search order lost due to use of dictionary keys instead of a list.
Closes SF bug #116964.
2000-10-16 15:47:50 +00:00
Barry Warsaw 293b03f73f translation(): Minor optimization patch which avoids instantiating the
default value's instance unless it's absolutely necessary.
2000-10-05 18:48:12 +00:00
Tim Peters c638791d53 Repaired comment. 2000-09-01 02:20:20 +00:00
Barry Warsaw 9a2d9d7f04 GNUTranslations._parse(): Fix portability problems on 64-bit machines
by masking all unsigned integers with 0xffffffff.
2000-08-31 23:28:52 +00:00
Barry Warsaw b76a55c278 GNUTranslations.BE_MAGIC: don't be so clever in calculating this from
LE_MAGIC; it breaks on Tru64.
2000-08-31 10:45:54 +00:00
Barry Warsaw 33d8d705b8 Finalize this module for Python 2.0 based on feedback and input from
Martin von Loewis, Peter Funk, James Henstridge, Francois Pinard, and
Marc-Andre Lemburg.
2000-08-30 03:29:58 +00:00
Barry Warsaw fa488ec2a0 _expand_lang(), _find(): Added support for unaliasing and expanded the
language found in the environment variable, contributed by James
Henstridge.
2000-08-25 20:26:43 +00:00
Barry Warsaw 84314b72d6 Group consensus is that supporting alternative locale categories is
useless.  So the category argument on _find() is removed, as is the
dcgettext() function.
2000-08-25 19:53:17 +00:00
Barry Warsaw 95be23dc86 Initial revision of gettext support for Python. This will undergo
some changes.
2000-08-25 19:13:37 +00:00