11

I created a Sitecore Form in Korean language (ko-Kr) version.

For an Email field on this form, we used Email Validator and updated the error message on this path /sitecore/system/Settings/Forms/Validations/Email Validator to Korean language.

Now if I type "" or if i enter an invalid email id, it is showing the validation error message in English language.

Whereas if I type "sd@s", I am getting error message which I configured for the validation item path /sitecore/system/Settings/Forms/Validations/Email Validator

enter image description here

If I type Alphanumeric character, it is showing error message in English.

Can someone suggest why I am getting the error message in English in this scenario?

enter image description here

6
  • I have done few major edits to your question. Please have a look to make sure the edits are not changing the context of your problem. Commented Apr 3, 2019 at 20:21
  • Is there any option to fix this issue?
    – PKH
    Commented Apr 10, 2019 at 12:25
  • What kind of validations do you have set for this field? Take a look here -> imgur.com/IxAkCLK Commented Apr 12, 2019 at 6:12
  • 3
    I think the only reliable answer to this will be from Sitecore Support. You should raise a ticket.
    – Mark Cassidy
    Commented Apr 12, 2019 at 6:16
  • @PeterProcházka - using Email validator for validation
    – PKH
    Commented Apr 12, 2019 at 6:18

3 Answers 3

10
+50

This is a known issue in Forms as it uses the default jQuery validation and there are no any localized scripts on custom language translations ootb. The issue is seen on the email validator - as long as jquery thinks it is a bad email, you will see the English text. After that you can see the translated text (the regex from Sitecore is different from the jquery one). There is a "wish" report to add support for the ootb languages and at least add documentation on how to fix this for other languages: https://kb.sitecore.net/articles/482062

I was told (by Support - thx to them) this should do it:

  1. Download jquery-validation source and extract the zip file
  2. Copy the jquery-validation-master\src\localization folder to the \sitecore modules\Web\ExperienceForms\scripts folder.
  3. Include the following script below the @RenderBody() helper in the \Views\Shared\MVCOuterLayout.cshtml file:

    <script type="text/javascript">
    var lang = '@Sitecore.Context.Language.Name';
    var script = document.createElement("script");
    if (lang == 'ko-KR')
    {
        script.src = "/sitecore%20modules/Web/ExperienceForms/scripts/localization/messages_ko.js";
        $("head").append(script);
    }
    </script>
    
  4. Find the error message in the \sitecore modules\Web\ExperienceForms\scripts\localization\messages_ko.js file and translate as desired. Should be something with email: "..."

You can also create a messages_<languageCode>.js file in the \sitecore modules\Web\ExperienceForms\scripts\localization folder and modify the script logic to handle other language translation.

Edit: Just verified this and it does seem to work fine.

If you need to do this in a SXA environment: https://ggullentops.blogspot.com/2019/04/sitecore-9-forms-translating-client-error.html

0
3

@Gatogordo - Thanks for sharing.

The easiest way we can fix this issue.

Step 1: Copy the "messages_ko.js" file and paste the to the \sitecore modules\Web\ExperienceForms\scripts folder.

Step 2: Give the "messages_ko.js" file name to the script field in Sitecore form and publish the item. Ex: enter image description here

Now it's reflecting the Korean language for email validation.

this is the custom message enter image description here

Custom message:

enter image description here

2
  • 1
    Glad to be of assistance ;) Didn't test it in the scripts field yet as that is shared. Curious how that behaves in a multi-lingual environment..
    – Gatogordo
    Commented Apr 16, 2019 at 7:17
  • We tested in multi-lingual environment. it will cause the translate content issue. correct solution -- we need to update script either sitecore form wrapper or layout.
    – PKH
    Commented May 6, 2019 at 11:01
0

There is an alternative solution, avoiding hardcoding the texts for other languages in javascript files:

Edit the file Views\FormBuilder\FieldTemplates\Email.cshtml and remove type="email" With this change, jQuery's validation doesn´t kick in, and you only get the regex validation of the email field, with its managed error message, avoiding the message "please enter a valid email address".

I would do the same on the view EmailConfirmation.cshtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.