What does __ mean in this context?

throw new Exception(__('exception')); 

What is he doing __? What are their names? I have seen this in several implementations and is distributed throughout the Magento code base.

thanks

+6
source share
2 answers

__ is the common name for the localization function. __ is a valid function name, like any other.

 function __($text) { // return localized text } 

How exactly this works depends on the structure in question.

+11
source

Usually, if you see __() or _() it, to pull the value of the string passed to the function from the i18n translation directory. Thus, the string passed to the function is scanned in the directory and the corresponding translation is returned.

+3
source

Source: https://habr.com/ru/post/893326/


All Articles