Let's say I have the following code:
define([
'jquery',
'mage/translate',
], function (
,ドル
$t
) {
'use strict';
return function (str) {
//Rest of codes to determine output
return $t(return_string);
});
}
I have all possible values of return_string on translate file. But it fails to translate at all on frontend. What can I do here to make return_string return translated string?
asked Aug 24, 2021 at 7:28
PY Yick
2,7051 gold badge19 silver badges35 bronze badges
-
Are you using this return_string somewhere? I mean in phtml or html?Abdul Samad Abbasi– Abdul Samad Abbasi2021年08月24日 09:21:50 +00:00Commented Aug 24, 2021 at 9:21
-
I use it on htmlPY Yick– PY Yick2021年08月25日 02:11:06 +00:00Commented Aug 25, 2021 at 2:11
-
Did you try translating it in html?Abdul Samad Abbasi– Abdul Samad Abbasi2021年08月25日 04:46:48 +00:00Commented Aug 25, 2021 at 4:46
-
I tried with no avail. Anyway, I solved it by inject the translated string in the file. Thanks for your help!PY Yick– PY Yick2021年08月27日 08:37:56 +00:00Commented Aug 27, 2021 at 8:37
1 Answer 1
I encountered this issue before. The problem is, that the "keys" that you want to translate need to be rendered in a phtml or HTML file first.
I usually do this in a hidden .
Msquare
9,4627 gold badges30 silver badges71 bronze badges
answered Aug 24, 2021 at 7:37
Philipp Sander
1,7332 gold badges14 silver badges27 bronze badges
-
Anyway, I solved it by inject the translated string in the file. Thanks for your help!PY Yick– PY Yick2021年08月27日 08:38:12 +00:00Commented Aug 27, 2021 at 8:38
default