Changeset 6446
- Timestamp:
- 10/02/07 20:57:02 (1 year ago)
- Files:
-
- django/trunk/django/utils/translation/__init__.py (modified) (4 diffs)
- django/trunk/django/utils/translation/trans_null.py (modified) (1 diff)
- django/trunk/django/utils/translation/trans_real.py (modified) (1 diff)
- django/trunk/tests/regressiontests/i18n/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/translation/__init__.py
r5609 r6446 3 3 """ 4 4 from django.utils.functional import lazy 5 from django.utils.encoding import force_unicode 5 6 6 7 __all__ = ['gettext', 'gettext_noop', 'gettext_lazy', 'ngettext', … … 40 41 41 42 # Make the originally requested function call on the way out the door. 42 return g[ caller](*args, **kwargs)43 return g['real_%s' % caller](*args, **kwargs) 43 44 44 45 g = globals() … … 64 65 return real_ungettext(singular, plural, number) 65 66 66 def string_concat(*strings):67 return real_string_concat(*strings)68 69 67 ngettext_lazy = lazy(ngettext, str) 70 68 gettext_lazy = lazy(gettext, str) 71 69 ungettext_lazy = lazy(ungettext, unicode) 72 70 ugettext_lazy = lazy(ugettext, unicode) 73 string_concat = lazy(string_concat, unicode)74 71 75 72 def activate(language): … … 109 106 return real_deactivate_all() 110 107 108 def string_concat(*strings): 109 """" 110 Lazy variant of string concatenation, needed for translations that are 111 constructed from multiple parts. 112 """ 113 return u''.join([force_unicode(s) for s in strings]) 114 string_concat = lazy(string_concat, unicode) django/trunk/django/utils/translation/trans_null.py
r5609 r6446 14 14 return force_unicode(ngettext(singular, plural, number)) 15 15 16 string_concat = lambda *strings: u''.join([force_unicode(el) for el in strings])17 16 activate = lambda x: None 18 17 deactivate = deactivate_all = install = lambda: None django/trunk/django/utils/translation/trans_real.py
r6263 r6446 517 517 return out.getvalue() 518 518 519 def string_concat(*strings):520 """"521 Lazy variant of string concatenation, needed for translations that are522 constructed from multiple parts.523 """524 return u''.join([force_unicode(s) for s in strings])django/trunk/tests/regressiontests/i18n/tests.py
r5876 r6446 31 31 >>> s == s4 32 32 False 33 34 unicode(string_concat(...)) should not raise a TypeError - #4796 35 36 >>> import django.utils.translation 37 >>> reload(django.utils.translation) 38 <module 'django.utils.translation' from ...> 39 >>> unicode(django.utils.translation.string_concat("dja", "ngo")) 40 u'django' 33 41 """
