Can validation error messages be multilingual?
This functionality is not supported by default. However, we came up with the workaround described below.
The following processor defined in the saveUI pipeline is called whenever an item is saved. It contains a single method called Process which validates the field values through the regular expressions defined for them on the template basis.
<processor mode="on" type="Sitecore.Pipelines.Save.ValidateFields, Sitecore.Kernel" />
To replace the default processor definition with a custom one, follow the steps below:
<processor mode="on" type="Custom.Pipelines.Save.ValidateFields, CustomValidateFields" />
Now we need to make some changes to the templates. Let’s assume that we have a template named Contact with the field named ZIP which contains the ZIP code value. Since we have two languages in the system, we need to set different validation error text and the validation expression for each language. In order to achieve this, we need to make the ValidationText field nonshared between languages. Let’s go to the Standard Template, locate this field and uncheck the Shared checkbox for it (and possibly for the Validation field as well):
Here is how the Contacts template is configured.
See the English version of the template in the picture below:
See the Danish version of the template in the picture below:
Note: We use even different validation expression for the ZIP field in Danish:
As a result, we get different error message boxes for each language: