1

I can't understand, why I can't write just echo "Agent", but I can write echo $this->__('Agent');? And what does this method do?

5

You can write echo "Agent" but you shouldn't write it, echo $this->__('Agent'); is right (recommended) as per Magento standards.

While you use echo $this->__('Agent');, you can translate Agent word to any other language (when you have multiple stores) by simply adding it to language translate csv. A simple echo will print same word for all stores.

3

You can write echo "Agent" but when you write echo $this->__('Agent') you can use the same word for translation.

When the __() method is called, Magento first looks for a translation in array matching the current module. The current module is determined by the class name on which the __() class is called.

2

Usually, these methods translate the phrase. Using direct echo call may lead to issues for multi-language sites

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.