2

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>

enter image description here

asked Apr 1, 2016 at 11:25

1 Answer 1

2

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>
Rafael Corrêa Gomes
13.9k15 gold badges92 silver badges190 bronze badges
answered Apr 1, 2016 at 13:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.