[Django] #33112: BaseValidator does not localize params passed to rendered ValidationError

4 views
Skip to first unread message

Django

unread,
Sep 15, 2021, 7:48:57 PM9/15/21
to django-...@googlegroups.com
#33112: BaseValidator does not localize params passed to rendered ValidationError
-------------------------------------+-------------------------------------
Reporter: JakeUrban | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 3.2
(Other) | Keywords: validators,
Severity: Normal | localization, i10n, error, message
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
django.core.validators.BaseValidator does not localize the values
contained in the params dict passed to ValidatorError. The result is that
error messages contain localized error messages with non-localized values.

Here is a photo of an english-style number included in a Portuguese error
message:

[[Image(https://ibb.co/nwNbsjx)]]

--
Ticket URL: <https://code.djangoproject.com/ticket/33112>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 15, 2021, 7:49:37 PM9/15/21
to django-...@googlegroups.com
#33112: BaseValidator does not localize params passed to rendered ValidationError
-------------------------------------+-------------------------------------
Reporter: JakeUrban | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution:
Keywords: validators, | Triage Stage:
localization, i10n, error, | Unreviewed
message |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by JakeUrban):

* Attachment "Screen Shot 2021-09-15 at 4.42.51 PM.png" added.

A Portuguese error message containing an english-style number.

Django

unread,
Sep 21, 2021, 4:37:36 AM9/21/21
to django-...@googlegroups.com
#33112: BaseValidator does not localize params passed to rendered ValidationError
-------------------------------------+-------------------------------------
Reporter: Jake Urban | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: validators, | Triage Stage:
localization, i10n, error, | Unreviewed
message |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => needsinfo


Old description:

> django.core.validators.BaseValidator does not localize the values
> contained in the params dict passed to ValidatorError. The result is that
> error messages contain localized error messages with non-localized
> values.
>
> Here is a photo of an english-style number included in a Portuguese error
> message:
>
> [[Image(https://ibb.co/nwNbsjx)]]

New description:

django.core.validators.BaseValidator does not localize the values
contained in the params dict passed to ValidatorError. The result is that
error messages contain localized error messages with non-localized values.

Here is a photo of an english-style number included in a Portuguese error
message:

[[Image(https://code.djangoproject.com/raw-
attachment/ticket/33112/Screen%20Shot%202021-09-15%20at%204.42.51%20PM.png)]]

--

Comment:

Hi Jake — thanks for the report. It's a tricky one.

I'm not 100% clear what the correct response here should be. Can I ask you
to follow up with more details to the
[https://forum.djangoproject.com/c/internals/i18n/14 i18n category on the
Django Forum] so we can get some more eyes on this?

What's the localization story we can tell for parameters in translated
error messages? 🤔

e.g. `limit_value` in `message = _('Ensure this value is greater than or
equal to %(limit_value)s.')`

Testing myself, I don't quite see the behaviour you're pointing to…

With `es` locale.

{{{
import decimal

from django import forms


class ExampleForm(forms.Form):
value = forms.DecimalField(
max_value=decimal.Decimal(100000.00),
min_value=decimal.Decimal(10.00),
max_digits=8,
decimal_places=2,
)
}}}

I see


{{{
>>> from forms import ExampleForm
>>> f = ExampleForm(data={'value':'1'})
>>> f.is_valid()
False
>>> f.errors
{'value': ['Asegúrese de que este valor es mayor o igual a 10.']}
}}}

Rather than `10.00` from your screenshot.

So, when you post, can you provide the full reproduce so we're all on
exactly the same page? Thanks!

I'll close as needsinfo here for the moment, but we can adjust that based
on the discussion.
(I hope that makes sense.)

--
Ticket URL: <https://code.djangoproject.com/ticket/33112#comment:1>

Django

unread,
Jan 21, 2025, 3:38:12 AMJan 21
to django-...@googlegroups.com
#33112: BaseValidator does not localize params passed to rendered ValidationError
-------------------------------------+-------------------------------------
Reporter: Jake Urban | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: validators, | Triage Stage:
localization, i10n, error, | Unreviewed
message |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Patrick Hintermayer):

Here's another case with a DateField:
https://forum.djangoproject.com/t/minvaluevalidator-with-localized-date-
format-message/38087/2
--
Ticket URL: <https://code.djangoproject.com/ticket/33112#comment:2>
Reply all
Reply to author
Forward
0 new messages