【问题标题】:Double underscore in cakephp 2.0cakephp 2.0 中的双下划线
【发布时间】:2012-02-16 21:48:38
【问题描述】:

我认为双下划线总是意味着私有函数,但在 cakephp 2.0 中,在这样的例子中它是什么意思 http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

例如

$this->Session->setFlash(__('The user could not be saved. Please, try again.'));

【问题讨论】:

  • Cake 不是唯一一个使用 __() 作为翻译/语言环境函数 stackoverflow.com/questions/1777131/double-underscore-in-php/… 的框架/平台
  • 因缺乏研究而被否决。
  • 我刚从 Cake 开始,并没有意识到双下划线是一种语言环境。谷歌搜索“PHP 双下划线”谈论魔术函数或其他内容,但搜索“cakephp 双下划线”将我引向您的问题和 Mike B 的答案。感谢您提出这个问题并忽略 luchomilina。

标签: php cakephp


【解决方案1】:

CakePHP 中的双下划线函数处理本地化。当您想通过提供字符串翻译字典来翻译您的应用程序时使用它。

Cake PHP Book: Global Constants & Functions

另见Internationalization and Localization

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 2020-11-28
    相关资源
    最近更新 更多