mirror of https://github.com/django/django.git
Fixed #5672 -- Allow the separator in the get_text_list utility function to be translated. Thanks, Claude.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14876 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
575962c213
commit
462d3115a3
Binary file not shown.
|
@ -5022,6 +5022,11 @@ msgstr "ديسمبر"
|
||||||
msgid "or"
|
msgid "or"
|
||||||
msgstr "أو"
|
msgstr "أو"
|
||||||
|
|
||||||
|
#. Translators: This string is used as a separator between list elements
|
||||||
|
#: utils/text.py:153
|
||||||
|
msgid ", "
|
||||||
|
msgstr "، "
|
||||||
|
|
||||||
#: utils/timesince.py:21
|
#: utils/timesince.py:21
|
||||||
msgid "year"
|
msgid "year"
|
||||||
msgid_plural "years"
|
msgid_plural "years"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import re
|
import re
|
||||||
from django.utils.encoding import force_unicode
|
from django.utils.encoding import force_unicode
|
||||||
from django.utils.functional import allow_lazy
|
from django.utils.functional import allow_lazy
|
||||||
from django.utils.translation import ugettext_lazy
|
from django.utils.translation import ugettext_lazy, ugettext as _
|
||||||
from htmlentitydefs import name2codepoint
|
from htmlentitydefs import name2codepoint
|
||||||
|
|
||||||
# Capitalizes the first letter of a string.
|
# Capitalizes the first letter of a string.
|
||||||
|
@ -148,7 +148,10 @@ def get_text_list(list_, last_word=ugettext_lazy(u'or')):
|
||||||
"""
|
"""
|
||||||
if len(list_) == 0: return u''
|
if len(list_) == 0: return u''
|
||||||
if len(list_) == 1: return force_unicode(list_[0])
|
if len(list_) == 1: return force_unicode(list_[0])
|
||||||
return u'%s %s %s' % (', '.join([force_unicode(i) for i in list_][:-1]), force_unicode(last_word), force_unicode(list_[-1]))
|
return u'%s %s %s' % (
|
||||||
|
# Translators: This string is used as a separator between list elements
|
||||||
|
_(', ').join([force_unicode(i) for i in list_][:-1]),
|
||||||
|
force_unicode(last_word), force_unicode(list_[-1]))
|
||||||
get_text_list = allow_lazy(get_text_list, unicode)
|
get_text_list = allow_lazy(get_text_list, unicode)
|
||||||
|
|
||||||
def normalize_newlines(text):
|
def normalize_newlines(text):
|
||||||
|
|
|
@ -4,12 +4,23 @@ from django.test import TestCase
|
||||||
from django.utils.text import *
|
from django.utils.text import *
|
||||||
from django.utils.http import urlquote, urlquote_plus, cookie_date, http_date
|
from django.utils.http import urlquote, urlquote_plus, cookie_date, http_date
|
||||||
from django.utils.encoding import iri_to_uri
|
from django.utils.encoding import iri_to_uri
|
||||||
|
from django.utils.translation import activate, deactivate
|
||||||
|
|
||||||
class TextTests(TestCase):
|
class TextTests(TestCase):
|
||||||
"""
|
"""
|
||||||
Tests for stuff in django.utils.text and other text munging util functions.
|
Tests for stuff in django.utils.text and other text munging util functions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def test_get_text_list(self):
|
||||||
|
self.assertEqual(get_text_list(['a', 'b', 'c', 'd']), u'a, b, c or d')
|
||||||
|
self.assertEqual(get_text_list(['a', 'b', 'c'], 'and'), u'a, b and c')
|
||||||
|
self.assertEqual(get_text_list(['a', 'b'], 'and'), u'a and b')
|
||||||
|
self.assertEqual(get_text_list(['a']), u'a')
|
||||||
|
self.assertEqual(get_text_list([]), u'')
|
||||||
|
activate('ar')
|
||||||
|
self.assertEqual(get_text_list(['a', 'b', 'c']), u"a، b أو c")
|
||||||
|
deactivate()
|
||||||
|
|
||||||
def test_smart_split(self):
|
def test_smart_split(self):
|
||||||
|
|
||||||
self.assertEquals(list(smart_split(r'''This is "a person" test.''')),
|
self.assertEquals(list(smart_split(r'''This is "a person" test.''')),
|
||||||
|
|
Loading…
Reference in New Issue