From 3c4c6e0f965f4523089c4700c4d2219902c803f0 Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Thu, 15 Dec 2005 15:56:26 +0000 Subject: [PATCH] fixes #1066 - yesno used the wrong way to do translations git-svn-id: http://code.djangoproject.com/svn/django/trunk@1673 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/template/defaultfilters.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/django/core/template/defaultfilters.py b/django/core/template/defaultfilters.py index 9fa6f4526f8..de6da35cbbb 100644 --- a/django/core/template/defaultfilters.py +++ b/django/core/template/defaultfilters.py @@ -2,6 +2,7 @@ from django.core.template import resolve_variable, Library from django.conf.settings import DATE_FORMAT, TIME_FORMAT +from django.utils.translation import gettext import re import random as random_module @@ -351,7 +352,7 @@ def divisibleby(value, arg): "Returns true if the value is devisible by the argument" return int(value) % int(arg) == 0 -def yesno(value, arg=_("yes,no,maybe")): +def yesno(value, arg=None): """ Given a string mapping values for true, false and (optionally) None, returns one of those strings accoding to the value: @@ -365,7 +366,9 @@ def yesno(value, arg=_("yes,no,maybe")): ``None`` ``"yeah,no"`` ``"no"`` (converts None to False if no mapping for None is given. ========== ====================== ================================== - """ + """ + if arg is None: + arg = gettext('yes,no,maybe') bits = arg.split(',') if len(bits) < 2: return value # Invalid arg. @@ -470,4 +473,4 @@ register.filter(urlize) register.filter(urlizetrunc) register.filter(wordcount) register.filter(wordwrap) -register.filter(yesno) \ No newline at end of file +register.filter(yesno)