Author: mtredinnick
Date: 2007-10-02 20:57:02 -0500 (Tue, 02 Oct 2007)
New Revision: 6446

Modified:
   django/trunk/django/utils/translation/__init__.py
   django/trunk/django/utils/translation/trans_null.py
   django/trunk/django/utils/translation/trans_real.py
   django/trunk/tests/regressiontests/i18n/tests.py
Log:
Fixed #4796. Fixed a problem when using i18n support for the first time -- in
particular when string_concat() was the first call made. Thanks, Andy Durdin.


Modified: django/trunk/django/utils/translation/__init__.py
===================================================================
--- django/trunk/django/utils/translation/__init__.py   2007-10-03 01:41:04 UTC 
(rev 6445)
+++ django/trunk/django/utils/translation/__init__.py   2007-10-03 01:57:02 UTC 
(rev 6446)
@@ -2,6 +2,7 @@
 Internationalization support.
 """
 from django.utils.functional import lazy
+from django.utils.encoding import force_unicode
 
 __all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext',
         'ngettext_lazy', 'string_concat', 'activate', 'deactivate',
@@ -39,7 +40,7 @@
             g['real_%s' % name] = getattr(trans, name)
 
     # Make the originally requested function call on the way out the door.
-    return g[caller](*args, **kwargs)
+    return g['real_%s' % caller](*args, **kwargs)
 
 g = globals()
 for name in __all__:
@@ -63,14 +64,10 @@
 def ungettext(singular, plural, number):
     return real_ungettext(singular, plural, number)
 
-def string_concat(*strings):
-    return real_string_concat(*strings)
-
 ngettext_lazy = lazy(ngettext, str)
 gettext_lazy = lazy(gettext, str)
 ungettext_lazy = lazy(ungettext, unicode)
 ugettext_lazy = lazy(ugettext, unicode)
-string_concat = lazy(string_concat, unicode)
 
 def activate(language):
     return real_activate(language)
@@ -108,3 +105,10 @@
 def deactivate_all():
     return real_deactivate_all()
 
+def string_concat(*strings):
+    """"
+    Lazy variant of string concatenation, needed for translations that are
+    constructed from multiple parts.
+    """
+    return u''.join([force_unicode(s) for s in strings])
+string_concat = lazy(string_concat, unicode)

Modified: django/trunk/django/utils/translation/trans_null.py
===================================================================
--- django/trunk/django/utils/translation/trans_null.py 2007-10-03 01:41:04 UTC 
(rev 6445)
+++ django/trunk/django/utils/translation/trans_null.py 2007-10-03 01:57:02 UTC 
(rev 6446)
@@ -13,7 +13,6 @@
 def ungettext(singular, plural, number):
     return force_unicode(ngettext(singular, plural, number))
 
-string_concat = lambda *strings: u''.join([force_unicode(el) for el in 
strings])
 activate = lambda x: None
 deactivate = deactivate_all = install = lambda: None
 get_language = lambda: settings.LANGUAGE_CODE

Modified: django/trunk/django/utils/translation/trans_real.py
===================================================================
--- django/trunk/django/utils/translation/trans_real.py 2007-10-03 01:41:04 UTC 
(rev 6445)
+++ django/trunk/django/utils/translation/trans_real.py 2007-10-03 01:57:02 UTC 
(rev 6446)
@@ -516,9 +516,3 @@
                 out.write(blankout(t.contents, 'X'))
     return out.getvalue()
 
-def string_concat(*strings):
-    """"
-    Lazy variant of string concatenation, needed for translations that are
-    constructed from multiple parts.
-    """
-    return u''.join([force_unicode(s) for s in strings])

Modified: django/trunk/tests/regressiontests/i18n/tests.py
===================================================================
--- django/trunk/tests/regressiontests/i18n/tests.py    2007-10-03 01:41:04 UTC 
(rev 6445)
+++ django/trunk/tests/regressiontests/i18n/tests.py    2007-10-03 01:57:02 UTC 
(rev 6446)
@@ -30,4 +30,12 @@
 >>> s4 = ugettext_lazy('Some other string')
 >>> s == s4
 False
+
+unicode(string_concat(...)) should not raise a TypeError - #4796
+
+>>> import django.utils.translation
+>>> reload(django.utils.translation)
+<module 'django.utils.translation' from ...>
+>>> unicode(django.utils.translation.string_concat("dja", "ngo"))
+u'django'
 """


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to