duanquan1207 2014-02-17 13:54
浏览 17
已采纳

Symfony2:如何手动设置区域设置?

Please, could you help me with this problem? However I set through link the _locale in symfony2 to english, it still takes the text in czech language and I don´t know, how to solve it. Please, help

$locale I get from session like this:

       $locale = $this->getRequest()->getSession()->get('_locale');

Here is file which contains repository method. http://pastebin.com/zbcvXttk

EDIT: After I changed the way how I get locale from previous to this:

   $locale = $this->getRequest()->getSession()->get('_locale');
   $this->get('gedmo.listener.translatable')->setTranslatableLocale($locale);  

It works, but there is problem, that it wrotes me for the first time I visit web this error:

Locale or language cannot be empty and must be set through Listener or Entity

I´m trying to find out some help on the net but still nothing

  • 写回答

1条回答 默认 最新

  • douzi7711 2014-02-17 15:35
    关注

    are you looking for this?

    $this->getRequest()->getSession()->set('_locale', 'en');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?