erp5_hal_json_style: Fix missing translation when validator return error
-
Owner
this seems very similar to 4e12f94c
maybe we forgot to update this one as well. The translation of validation messages in ERP5JS is not tested yet ?
In any case, we should probably use the
getMessage
API here as well. -
Developer
I'm fixing test now, I will try to change to
getMessage
thanks Jérome -
Developer
Indeed, we should also make sure that things are not translated twice (and get translation of translation in Localizer).
But I do not understand why 4e12f94c was not already enough in this case, I think it should be applied in all error message.
-
Owner
Indeed, we should also make sure that things are not translated twice (and get translation of translation in Localizer).
Yes, this might be something we could cover in tests one day, with an approach like this:
diff --git a/product/Localizer/Localizer.py b/product/Localizer/Localizer.py index a199acd6a2..494787241a 100644 --- a/product/Localizer/Localizer.py +++ b/product/Localizer/Localizer.py @@ -38,6 +38,12 @@ from .utils import lang_negotiator from .LanguageManager import LanguageManager +import six +class TranslatedString(six.text_type): + """A message that was already translated. + """ + pass + # Constructors manage_addLocalizerForm = LocalDTMLFile('ui/Localizer_add', globals()) @@ -280,7 +286,8 @@ class Localizer(LanguageManager, Folder): assert not args if lang is not None: kw['target_language'] = lang - return translate(to_unicode(msgid), domain=domain, **kw) + assert not isinstance(msgid, TranslatedString) + return TranslatedString(translate(to_unicode(msgid), domain=domain, **kw)) InitializeClass(Localizer)
( it would be much more complicated, it's just a patch to explain the idea )
But I do not understand why 4e12f94c was not already enough in this case, I think it should be applied in all error message.
I don't know either