php - Symfony2: How to set the locale manually?

35

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

479

Answer

Solution:

are you looking for this?

$this->getRequest()->getSession()->set('_locale', 'en');

People are also looking for solutions to the problem: sql - Display a single record from a database with multiple duplicates PHP

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.