Categories


Archives


Recent Posts


Categories


Magento 2: Single Translation Function

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Magento 1 was littered with translation functions. Helper objects, block objects, and the PHP global namespace all had a __ function or method.

Magento 2 does away with this. Core team developers have removed the __ method from the base block and helper classes, leaving only the global __ function for translations.

If that didn’t make sense: In templates you used to say

echo $this->__('Hello World');

Now you say

echo __('Hello World');

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 10th November 2013

email hidden; JavaScript is required