0

I met a problem that how to translate the module's phrase into other languages(eg. Japanese).

For example, some code may like this:

app/code/My_vendor/My_module/Controller/i18n/jp_JP.csv

"test","Japanese character"

app/code/My_vendor/My_module/Controller/index.php

......
$form = '<h3>test</h3>';
$this->getResponse()->setBody($form);
......

If STORES->Configuration->Locale Options is selected with English(United States), it will show "test" to users; if Japanese(Japan) is selected, it will show "Japanese character".

I had seen the tutorial  http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/xlate.html but I'm not sure what should I do next.

2 Answers 2

5

2 points: You placed translate file into wrong place. The correct path should be app/code/<My_vendor>/<My_module>/i18n/jp_JP.csv.

And you didn't use __('text to translate') to parse the text to translate in template file.

So in your case, change $form = '<h3>test</h3>'; to $form = '<h3>' . __('test') . '</h3>';

0
8

Translation file path should be

app/code/My_vendor/My_module/i18n/jp_JP.csv

You should write a translate text code in your controller

app/code/<My_vendor>/<My_module>/Controller/index.php

like below

$form = '<h3>' . __('test') . '</h3>';
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.