2

I am working with Magento XML files and I found

translate=" label"

 <tabs>
     <training translate="label" module="training">
         <label>training</label>
         <sort_order>50</sort_order>
     </training>
 </tabs>

I want to know how it works?

1

A workaround would be to use the translate attribute to tell which other attributes to translate.

<tabs>
     <training translate="label" module="training">
         <label>training</label>
         <sort_order>50</sort_order>
     </training>
 </tabs>

In your example translate="label" where label is a attribute and it will translate the value of <label>training</label>


More Explanation


  • Magento present the user interface in different languages without modifying the actual application source code. it translates the system messages, error messages, and labels for display in the UI.
  • Some messages may be displayed in logs for a system administrator or a developer—those don't need to be translated.
  • By convention, in the source code, the labels and system messages for UI are expressed in English (en_US).
  • In order to replace these phrases with alternatives in different languages when the source code is interpreted, Magento has a layer of indirection.

In XML files, the conventional translate and module attributes indicate that the contents of a node must be translated:

<tabs>
     <training translate="label" module="training">
         <label>training</label>
         <sort_order>50</sort_order>
     </training>
 </tabs>

The translate indicates a child node that contains the phrase, and "module" indicates context of a module.

Context indicates a kind of namespace for this phrase.

  • 1
    Thanks, now I understand what is this used for. – Smita Kagwade Apr 24 at 7:55
  • Anytime :) Happy coding ! – Aditya Shah Apr 24 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.