在实体中获取文化/本地

时间:2013-09-25 17:40:10

标签: php symfony doctrine-orm

我只是实体:

/**
 * Claudio\PageBundle\Entity\Page
 */
class Page
{
//
    private $id;

    private $title;

    private $text_en;

    private $text_fr;

    //getters and setters for all
}

我会为这个吸气者添加:

public function getText()
{
    $culture = ???;
    if($culture == 'en') return $this->getTextEn();
    if($culture == 'fr') return $this->getTextFr();
}

但我怎样才能在Entity课程中获得Culture / Local?我知道 - 我可以通过使用Controller或Twig来实现它,但我想在所有视图中使用它来通过$ page-> getText()。可以在实体中制作吗?

1 个答案:

答案 0 :(得分:1)

setlocale(LC_ALL,0);

将返回已设置的语言环境。 它可能会返回多个区域设置。

相关问题