1
0
mirror of https://github.com/django/django.git synced 2024-12-24 18:16:19 +00:00

Removed Python 2.3 compat code in translation framework.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12446 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2010-02-16 12:16:01 +00:00
parent 89df0432f2
commit 16942e178f
2 changed files with 2 additions and 29 deletions

View File

@ -3,11 +3,6 @@ import sys
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
try:
set
except NameError:
from sets import Set as set # For Python 2.3
def compile_messages(locale=None):
basedirs = [os.path.join('conf', 'locale'), 'locale']
if os.environ.get('DJANGO_SETTINGS_MODULE'):

View File

@ -60,7 +60,7 @@ class DjangoTranslation(gettext_module.GNUTranslations):
"""
This class sets up the GNUTranslations context with regard to output
charset. Django uses a defined DEFAULT_CHARSET as the output charset on
Python 2.4. With Python 2.3, use DjangoTranslation23.
Python 2.4.
"""
def __init__(self, *args, **kw):
from django.conf import settings
@ -87,23 +87,6 @@ class DjangoTranslation(gettext_module.GNUTranslations):
def __repr__(self):
return "<DjangoTranslation lang:%s>" % self.__language
class DjangoTranslation23(DjangoTranslation):
"""
Compatibility class that is only used with Python 2.3.
Python 2.3 doesn't support set_output_charset on translation objects and
needs this wrapper class to make sure input charsets from translation files
are correctly translated to output charsets.
With a full switch to Python 2.4, this can be removed from the source.
"""
def gettext(self, msgid):
res = self.ugettext(msgid)
return res.encode(self.django_output_charset)
def ngettext(self, msgid1, msgid2, n):
res = self.ungettext(msgid1, msgid2, n)
return res.encode(self.django_output_charset)
def translation(language):
"""
Returns a translation object.
@ -121,11 +104,6 @@ def translation(language):
from django.conf import settings
# set up the right translation class
klass = DjangoTranslation
if sys.version_info < (2, 4):
klass = DjangoTranslation23
globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
if settings.SETTINGS_MODULE is not None:
@ -147,7 +125,7 @@ def translation(language):
def _translation(path):
try:
t = gettext_module.translation('django', path, [loc], klass)
t = gettext_module.translation('django', path, [loc], DjangoTranslation)
t.set_language(lang)
return t
except IOError, e: