在前端翻译我的magento自定义模块 [英] Translate my magento custom module in frontend
本文介绍了在前端翻译我的magento自定义模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经完成了一个magento定制模块,我想为其翻译.
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 ?
非常感谢.
推荐答案
您可以使用内置的翻译方法,并在模板中定义所有字符串,如下所示:
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');?>
,如果您需要定义自己的翻译文件,请在etc/config.xml中使用它
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>
这篇关于在前端翻译我的magento自定义模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文