php – Magento ::从javascript文件翻译文本

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – Magento ::从javascript文件翻译文本脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
Magento使用系统翻译模板文件中的文本:

$this-> __(‘要翻译的文字.’);

要么

Mage :: helPEr(‘modulename’) – > __(‘要翻译的文字.’);.

这非常有效.
但是当我向javascript文件添加文本时,我无法使用这两种方法.

有没有办法我可以用javascript文件的翻译做类似的事情?

您可以在模板文件yourfile.phtML中执行此操作. javascript脚本js / mage / translate.js必须包含在你的html标头中(认情况下Magento会这样做).
<script type="text/javascript">
Translator.add('You should take care of this confirmation message!','<?PHP echo Mage::helper('yourmodule')->__('You should take care of this confirmation message!')?>');
</script>

编辑:
您可以从Magento 1.7中将文件jstranslator.XMl添加到etc /文件夹下的模块中,并设置以下字符串:

<jstranslator>
    <!-- validation.js -->
    <validate-no-html-tags translate="message" module="core">
        <;message>HTML tags are not Allowed</message>
    </validate-no-html-tags>
    <validate-select translate="message" module="core">
        <message>Please select an option.</message>
    </validate-select>
</jstranslator>

感谢CSV文件,然后在为PHP执行此操作时翻译字符串这个,将添加到javascript代码的翻译,如下面的VAR Translator = new Translate(…)

脚本宝典总结

以上是脚本宝典为你收集整理的php – Magento ::从javascript文件翻译文本全部内容,希望文章能够帮你解决php – Magento ::从javascript文件翻译文本所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。