Hmm, I see that the framework does add the T translator to the Validator 
class, so validation messages should be getting translated. There is 
nothing special about Auth extra_fields -- the validators you add there are 
no different from the validators added to other fields.

Can you give an example of code using the same validator where the message 
is translated outside of extra_fields but not within extra_fields?

Also, in your example, you mentioned when setting T.force('pt'), all 
messages came out in Portuguese, even if you "change the language to 
English". What do you mean by "change the language to English" there? 
Setting T.force('pt') should force all translations to Portuguese unless 
you override the T.force('pt').

Finally, are you running/sending requests to more than one application, not 
all of which have the same translation files?

Anthony

On Friday, April 5, 2019 at 2:03:57 PM UTC-4, João Matos wrote:
>
> All my other error messages (from built-in validators) are 
> auto-translated. Including for the default auth_user fields (eg. username). 
> Only the extra_fields are not.
>
> Is there a fix?
>
>
> sexta-feira, 5 de Abril de 2019 às 18:56:10 UTC+1, Anthony escreveu:
>>
>> Note, this is due to the recent refactoring of all built-in validators 
>> (moved from web2py to pydal). Previously, all default error messages were 
>> translated, but that is no longer the case. Although the automatic 
>> translation was not documented, I would still consider this a break in 
>> backward compatibility (particularly given that all Auth error messages are 
>> still being translated automatically).
>>
>> Anthony
>>
>> On Thursday, April 4, 2019 at 3:25:10 PM UTC-4, João Matos wrote:
>>>
>>> When creating extra fields for auth_user, the validation messages for 
>>> those fields are always in English. They don't comply with the translations 
>>> available.
>>>
>>> This does not happen on the default fields.
>>>
>>>
>>> I added this to db.py
>>>
>>>
>>> auth.settings.extra_fields['auth_user'] = [Field('pagination', 'integer'
>>> , default=9, label=T('Pagination'), notnull=True, required=True, 
>>> requires=IS_INT_IN_RANGE(5, 51))] 
>>>
>>>
>>> When inserting an invalid value, the returned message is always
>>>
>>> Enter an integer between 5 and 50
>>>>
>>> even when the web2py language is not English and the languages files 
>>> have the correct translation available.
>>>
>>>
>>> web2py 2.18.4
>>> Python 3.7.1 x86
>>> Firefox 66.0.2 x64
>>> Windows 7 Pro x64 SP1+all updates
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to