4

I have done a magento custom module and I want to make a translation for it.

How can I do that, without creating another translation module ?

Thanks a lot.

1 Answer 1

9

You can use built in translation methods and define all your strings in templates like this:

<?php echo $this->__('yourtext'); ?> 

if you need to use strings in classes or blocks you can get the context from helper class like this:

<?php echo Mage::helper('yourextension')->__('yourtext');?> 

and if you need to define your own translation file then use this in your etc/config.xml

<config> <frontend> <translate> <modules> <Your_Extension> <files> <default>Your_Extension.csv</default> </files> </Your_Extension> </modules> </translate> </frontend> </config> 
Sign up to request clarification or add additional context in comments.

5 Comments

the first $this->__('youtext') method will work for blocks as well. And for controllers. Only models need the second way.
the place to put your translation is app/locale/language_CODE/Your_Extension.csv
it is locale_CODE not language_CODE
Use Magento 2 translation CSV files in i18n/<locale_code>.csv inside your module, then clear cache. This will translate your frontend text.
Set the checkbox value in your module’s form/data using: php $field->setIsChecked(true); or in the UI component XML: xml <item name="checked" xsi:type="boolean">true</item>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.