Magento – Magento 2: Validate error from review form on product page does not translate

inputlocalisationmagento2review

The message 'Please select one of each of the ratings above.' is not translating, when you try to add a review without choosing the stars.

The form is located in the file form.phtml

vendor/magento/module-review/view/frontend/templates

And the validation error is shown like this

    <input
        type="radio"
        name="ratings[<?php /* @escapeNotVerified */ echo $_rating->getId() ?>]"
        id="<?php echo $block->escapeHtml($_rating->getRatingCode()) ?>_<?php /* @escapeNotVerified */ echo $_option->getValue() ?>"
        value="<?php /* @escapeNotVerified */ echo $_option->getId() ?>"
        class="radio"
        data-validate="{required:true, messages:{required:'Please select one of each of the ratings above.'}}"
        aria-labelledby="<?php echo $block->escapeHtml($_rating->getRatingCode()) ?>_rating_label <?php echo $block->escapeHtml($_rating->getRatingCode()) ?>_<?php /* @escapeNotVerified */ echo $_option->getValue() ?>_label"
/>

I tried to change it with

data-validate="{required:true, messages:{required: <?php __('Please select one of each of the ratings above.') ?> }}"

But it's not working.

How can I translate this validation error?

Best Answer

This is currently a default Magento 2.2 bug.

It should be fixed in the next release (Magento v 2.2.2).

As a temporary solution you could try creating your own validation class as suggested here: https://github.com/magento/magento2/issues/10474

Related Topic