0

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
4
  • Are you using this return_string somewhere? I mean in phtml or html? Commented Aug 24, 2021 at 9:21
  • I use it on html Commented Aug 25, 2021 at 2:11
  • Did you try translating it in html? Commented 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! Commented Aug 27, 2021 at 8:37

1 Answer 1

0

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
1
  • Anyway, I solved it by inject the translated string in the file. Thanks for your help! Commented Aug 27, 2021 at 8:38

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.