如何在phtml文件中添加文本内容以进行翻译

sam*_*har 2 translation magento

我需要在.phtml文件中添加文本内容,以便我可以将其翻译为多语言网站.

文件位置:app> design> frontend> default>(my-theme)> template> catalog> category> left_nav.phtml

Mar*_*ius 12

选项1.

<?php echo Mage::helper('catalog')->__('Text here');?>
Run Code Online (Sandbox Code Playgroud)

然后添加文本 app/locale/{lang_ISO}/Mage_Catalog.csv

"Text here","Translation here"
Run Code Online (Sandbox Code Playgroud)

选项2.

<?php echo $this->__('Text here');?>
Run Code Online (Sandbox Code Playgroud)

然后app/design/frontend/{interface}/{theme}/locale/{lang_ISO}/translate.csv像这样添加文本:

"Text here","Translation here"
Run Code Online (Sandbox Code Playgroud)

[编辑]
要在文本中包含链接,请遵循以下模式:

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

然后将此行添加到您的csv文件中:

"some <a href=""%s"">text here</a>","translated <a href=""%s"">text here</a>"
Run Code Online (Sandbox Code Playgroud)

%s是一个占位符,将被__方法的第二个参数替换.
此外,当将其添加到csv文件时,请确保将文本内部的引号加倍,因此<a href="%s"></a>应将其添加到csv文件中<a href=""%s""></a>