Answer the question
In order to leave comments, you need to log in
Why are language variables in M2 translated normally by means of php, but not by means of js?
Such a question is ripe:
there are 2 different language locales in M2 - en and de
Many variables of their own, everything is fine if you output from the phtml template - echo __('Variable name').
Here I wanted to make a small edit with Javascript, but also to display a string depending on the locale.
There is quite a lot on the topic in Google, such a simple construction is offered
require([
'jquery', // jquery Library
'jquery/ui', // Jquery UI Library
'mage/translate' // Magento text translate (Validation message translte as per language)
], function($){
$(window).load(function() {
alert($.mage.__('Fast Shipping'));
});
});
Answer the question
In order to leave comments, you need to log in
in the translation file de_De.csv.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question