I had spent more than 3 hours, but did not find solution. If subscribe field on home page empty we will get JS message 'This is a required field.' How it may be translated by inline translate (using book on FE). When I inserted to the table TRANSLATE (by sql) string manually, it's working. So, how show book for inline translation for js popups errors? enter image description here
I try use this in my subscribe.phtml, but this not work correctly (translated data added to DB, but original string "This is a required field." is empty. why?)
<script>
require([
'jquery',
'jquery/ui',
'mage/translate'
], function ($) {
$(window).load(function () {
$.mage.__(<?php echo json_encode(__('This is a required field.'))?>);
});
});
</script>
1 Answer 1
I found solution for CSV translates, but not for inline.
1. Add to CSV:
"This is a required field.","This is a required field!!!"
2. Add code to phtml:
<script>
require([
'jquery',
'mage/translate'
], function ($) {
$(window).load(function () {
var translates = <?php echo \Zend_Json::encode(
array(
'This is a required field.' => __('This is a required field.'),
)
)?>;
$.mage.translate.add(translates);
});
});
</script>