How do I add text content in a phtml file for translation

13,198

Option 1.

<?php echo Mage::helper('catalog')->__('Text here');?>

Then add the text in app/locale/{lang_ISO}/Mage_Catalog.csv

"Text here","Translation here"

Option 2.

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

Then add the text in app/design/frontend/{interface}/{theme}/locale/{lang_ISO}/translate.csv like this:

"Text here","Translation here"

[EDIT]
To include links in the text follow this pattern:

<?php echo $this->__('some <a href="%s">text here</a>', Mage::getUrl('some/url/here'));

Then add to your csv file this line:

"some <a href=""%s"">text here</a>","translated <a href=""%s"">text here</a>"

%s is a placeholder that will be replaced by the second parameter of __ method.
Also when adding it to the csv file make sure you double the quotes inside the text so <a href="%s"></a> should be added to the csv file like <a href=""%s""></a>

Share:
13,198
sameermanandhar
Author by

sameermanandhar

I do Web Development, responsive website, CSS, twitter bootstrap, Magento Developer, Wordpress Developer, and also work on Outsourced website projects.

Updated on June 15, 2022

Comments

  • sameermanandhar
    sameermanandhar almost 2 years

    I need to add text content in a .phtml file so that I can get it translated for multilingual site.

    file location here: app > design > frontend > default > (my-theme) > template > catalog > category > left_nav.phtml