Hello Magento Folks,
How are you all? Hope I have reached you safely. In this illustration, I will teach you How To Translate JS Error Message In Magento 2. Make sure you have read our previously published blog How to setup Buy X Get Y Free in Magento 2. Let Get Started.
Quick Summary:
All E-commerce business owners wish to sell globally. The primary thing that comes across this is the language. Let me help you. Basically, Magento 2 is one of the widespread platforms used for creating a featured E-commerce store. Translation facilitates the Magento 2 Merchants to translate language for their customers. It helps the Magento 2 store merchants to assist their customers by utilizing different languages from various parts of the world.
Your customers will be displayed in their used native language that helps in increasing the customer experience and your store becomes more friendly and more suitable locally. Let’s check how we can Translate JS Error Message In Magento 2
Steps to Translate JS Error Message In Magento 2:
Step 1: You can make use of the below code To Translate JS Error Message In Magento 2:
require([ 'jquery', // jquery Library 'mage/translate' ], function($,$t){ $(window).load(function() { alert($t('Enter Your message here')); // Here $t is use to translate text }); }); OR require([ 'jquery', // jquery Library 'mage/translate' ], function($){ $(window).load(function() { alert($.mage.__('Enter Your message here')); // Here $.mage.__ is use to translate text }); });
Great job, that’s a work to Translate JS Error Message In Magento 2.
Final Say:
Hence, with the use of the above code, you have learned How To Translate JS Error Message In Magento 2. In the above process if you feel any difficulties then you can ask me in the comment section below.
Share the method with your Magento friends using Social media.
Happy Reading!
Hi Gaurav,
just want to ask you if this work as well?
9
10
11
12
13
14
15
16
17
<?php
require(['jquery', // jquery Library
'mage/translate' // Magento text translate], function ($){
$(window).load(function ()
{
alert($.mage . __('Enter Your message here'));
// here $.mage.__() used to translate text
});
});
ORrequire(['jquery', // jquery Library
'mage/translate'], function ($,$t)
{
$(window).load(function ()
{
alert($t('Enter Your message here'));
});
});
Looking for your reply!
Thanks