Skip to content

Commit 9496ae6

Browse files
authored
MAGETWO-80224: Error message in product review form not being translated #11069
2 parents ee24d30 + 9a16f0f commit 9496ae6

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

app/code/Magento/Review/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ Summary,Summary
132132
"Allow Guests to Write Reviews","Allow Guests to Write Reviews"
133133
Active,Active
134134
Inactive,Inactive
135+
"Please select one of each of the ratings above.","Please select one of each of the ratings above."

app/code/Magento/Review/view/frontend/templates/form.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
id="<?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>"
3636
value="<?= $block->escapeHtmlAttr($_option->getId()) ?>"
3737
class="radio"
38-
data-validate="{required:true, messages:{required:'Please select one of each of the ratings above.'}}"
38+
data-validate="{ 'rating-required':true}"
3939
aria-labelledby="<?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_rating_label <?= $block->escapeHtmlAttr($_rating->getRatingCode()) ?>_<?= $block->escapeHtmlAttr($_option->getValue()) ?>_label" />
4040
<label
4141
class="rating-<?= $block->escapeHtmlAttr($iterator) ?>"
@@ -85,7 +85,8 @@
8585
"Magento_Ui/js/core/app": <?= /* @noEscape */ $block->getJsLayout() ?>
8686
},
8787
"#review-form": {
88-
"Magento_Review/js/error-placement": {}
88+
"Magento_Review/js/error-placement": {},
89+
"Magento_Review/js/validate-review": {}
8990
}
9091
}
9192
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'jquery/ui',
9+
'jquery/validate',
10+
'mage/translate'
11+
], function ($) {
12+
'use strict';
13+
14+
$.validator.addMethod(
15+
'rating-required', function (value) {
16+
return value !== undefined;
17+
}, $.mage.__('Please select one of each of the ratings above.'));
18+
});

0 commit comments

Comments
 (0)