php – Magento ::从javascript文件翻译文本
发布时间:2020-12-13 13:40:58 所属栏目:PHP教程 来源:网络整理
导读:Magento使用系统翻译模板文件中的文本: $this- __(‘要翻译的文字.’); 要么 Mage :: helper(‘modulename’) – __(‘要翻译的文字.’);. 这非常有效. 但是当我向javascript文件添加文本时,我无法使用这两种方法. 有没有办法我可以用javascript文件的翻译
Magento使用系统翻译模板文件中的文本:
$this-> __(‘要翻译的文字.’); 要么 Mage :: helper(‘modulename’) – > __(‘要翻译的文字.’);. 这非常有效. 有没有办法我可以用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> 编辑: <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(…) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |