Ticket #5672: list_separator_translatable.diff

File list_separator_translatable.diff, 1.1 KB (added by Claude Paroz, 14 years ago)

Make list separator translatable

  • django/utils/text.py

    diff --git a/django/utils/text.py b/django/utils/text.py
    index b054604..d5b3fce 100644
    a b  
    11import re
    22from django.utils.encoding import force_unicode
    33from django.utils.functional import allow_lazy
    4 from django.utils.translation import ugettext_lazy
     4from django.utils.translation import ugettext_lazy, ugettext as _
    55from htmlentitydefs import name2codepoint
    66
    77# Capitalizes the first letter of a string.
    def get_text_list(list_, last_word=ugettext_lazy(u'or')):  
    148148    """
    149149    if len(list_) == 0: return u''
    150150    if len(list_) == 1: return force_unicode(list_[0])
    151     return u'%s %s %s' % (', '.join([force_unicode(i) for i in list_][:-1]), force_unicode(last_word), force_unicode(list_[-1]))
     151    return u'%s %s %s' % (
     152        # Translators: This string is used as a separator between list elements
     153        _(', ').join([force_unicode(i) for i in list_][:-1]),
     154        force_unicode(last_word),
     155        force_unicode(list_[-1]))
    152156get_text_list = allow_lazy(get_text_list, unicode)
    153157
    154158def normalize_newlines(text):
Back to Top