开发者

What do the __'s mean in this context?

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

What do the __'s d开发者_开发百科o? What are they called? I've seen this in several implementations and is common throughout the Magento codebase.

Thanks


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

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

How exactly it works depends on the framework in question.


Usually if you see __() or _() its to pull the value of the string passed into the function from an i18n translation catalog. So the string passed to the function is looked up in the catalog and the appropriate translation is returned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜