From f34777a2e9241e4995bd558eede616f872e65b57 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 28 Aug 2015 14:55:22 +0100 Subject: [PATCH] Translations for HTML filters --- rest_framework/filters.py | 3 ++- rest_framework/templates/rest_framework/admin.html | 2 +- rest_framework/templates/rest_framework/base.html | 3 ++- .../templates/rest_framework/filters/django_filter.html | 5 +++-- .../rest_framework/filters/django_filter_crispyforms.html | 3 ++- .../templates/rest_framework/filters/ordering.html | 3 ++- rest_framework/templates/rest_framework/filters/search.html | 3 ++- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index c231f574c..f3b282a21 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -12,6 +12,7 @@ from django.core.exceptions import ImproperlyConfigured from django.db import models from django.template import Context, loader from django.utils import six +from django.utils.translation import ugettext_lazy as _ from rest_framework.compat import ( crispy_forms, distinct, django_filters, get_model_name, guardian @@ -31,7 +32,7 @@ if 'crispy_forms' in settings.INSTALLED_APPS and crispy_forms and django_filters field.help_text = None layout_components = list(self.form.fields.keys()) + [ - Submit('', 'Submit', css_class='btn-default'), + Submit('', _('Submit'), css_class='btn-default'), ] helper = FormHelper() diff --git a/rest_framework/templates/rest_framework/admin.html b/rest_framework/templates/rest_framework/admin.html index 41a942a14..f670cfe20 100644 --- a/rest_framework/templates/rest_framework/admin.html +++ b/rest_framework/templates/rest_framework/admin.html @@ -116,7 +116,7 @@ {% if filter_form %} {% endif %} diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html index 71075ad89..fbf1e9824 100644 --- a/rest_framework/templates/rest_framework/base.html +++ b/rest_framework/templates/rest_framework/base.html @@ -1,5 +1,6 @@ {% load staticfiles %} {% load rest_framework %} +{% load i18n %} @@ -112,7 +113,7 @@ {% if filter_form %} {% endif %} diff --git a/rest_framework/templates/rest_framework/filters/django_filter.html b/rest_framework/templates/rest_framework/filters/django_filter.html index c3f914581..b116e3531 100644 --- a/rest_framework/templates/rest_framework/filters/django_filter.html +++ b/rest_framework/templates/rest_framework/filters/django_filter.html @@ -1,5 +1,6 @@ -

Field filters

+{% load i18n %} +

{% trans "Field filters" %}

{{ filter.form.as_p }} - +
diff --git a/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html b/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html index 5240a4307..171767c08 100644 --- a/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html +++ b/rest_framework/templates/rest_framework/filters/django_filter_crispyforms.html @@ -1,4 +1,5 @@ {% load crispy_forms_tags %} +{% load i18n %} -

Field filters

+

{% trans "Field filters" %}

{% crispy filter.form %} diff --git a/rest_framework/templates/rest_framework/filters/ordering.html b/rest_framework/templates/rest_framework/filters/ordering.html index d978c6346..b71b2a5bf 100644 --- a/rest_framework/templates/rest_framework/filters/ordering.html +++ b/rest_framework/templates/rest_framework/filters/ordering.html @@ -1,5 +1,6 @@ {% load rest_framework %} -

Ordering

+{% load i18n %} +

{% trans "Ordering" %}

{% for key, label in options %} {% if key == current %} diff --git a/rest_framework/templates/rest_framework/filters/search.html b/rest_framework/templates/rest_framework/filters/search.html index 7c4ce4915..edb28d45d 100644 --- a/rest_framework/templates/rest_framework/filters/search.html +++ b/rest_framework/templates/rest_framework/filters/search.html @@ -1,4 +1,5 @@ -

Search

+{% load i18n %} +

{% trans "Search" %}