Magento,翻译验证错误消息 [英] Magento, translate validation error messages

查看:79
本文介绍了Magento,翻译验证错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功创建了用于原型验证的新规则,现在我需要翻译错误消息(位置:Javascript中的String).但是,我只能翻译所有消息,我的新自定义消息似乎不可翻译.我该如何更改?

I have successfully created new rules for the prototype validation, now I need to translate the error messages (Location: String in Javascript). However, I can only translate all the messages, my new custom ones don't appear to be translatable. How do I change this?

推荐答案

也许您需要在etc文件夹中的jstranslator.xml文件:

Maybe you need an jstranslator.xml file inside etc folder:

<?xml version="1.0" encoding="UTF-8"?>
<jstranslator>
  <some-message-name translate="message" module="mymodule">
    <message>This is the text in my own js validation</message>
  </some-message-name>
</jstranslator>

具有以下结构和含义:

  • <jstranslator>-[一个] XML根节点.
    • <some-message-name>-[零个或多个]根节点子元素,在所有jstranslator.xml文件中具有唯一的XML元素名称(否则,根据模块列表的成功,加载顺序排在最后).
      • 属性:
      • translate="message"-(可选)提示正在翻译的子元素被命名为"message",但是对于js转换XML文件进行了硬编码(Magento CE 1.9,搜索"*/message),则不需要使用此属性.
      • module="mymodule"-(可选)模块名称,如果省略,则值为"core".稍后将用于(从该模块)实例化数据帮助器,然后负责加载翻译(例如,从CSV文件).
      • <jstranslator> - [one] XML root node.
        • <some-message-name> - [zero or more] root node child elements with a unique XML element name across all jstranslator.xml files (otherwise last in loading order based on module listing wins).
          • Attributes:
          • translate="message" - (optional) a hint that the child element(s) that is being translated is named "message", however this is hardencoded for the js translation XML files (Magento CE 1.9, search for "*/message") and this attribute does not need to be used.
          • module="mymodule" - (optional) name of the module, if left out the value is "core". It will be used to instantiate the data-helper later on (from that module) which then is reponsible to load the translations (e.g. from the CSV files).

          所有已激活 模块的jstranslator.xml文件.

          All jstranslator.xml files of activated modules are processed.

          然后将您的翻译行放入Something_Mymodule.csv文件:

          Then put your translation line into the Something_Mymodule.csv file:

          "This is the text in my own js validation", "(translated in a different language or speech)"
          

          然后在您的js脚本中,您可以通过翻译器使用自己的翻译:

          Then in your js scripts you can use your own translations via the Translator:

          Translator.translate('This is the text in my own js validation');
          

          其他参考

          • 正确使用jstranslator.xml
          • Further References

            • Correct usage of jstranslator.xml
            • 这篇关于Magento,翻译验证错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆