Hi everyone,
I have made a website in Laravel, a multilingual website, so far English and French. To change the language there is a route declared Route::get('home/lang/{any}','HomeController@getLang');
Then in the HomeController
public function getLang (Request $request , $lang)
{$request->session()->put('lang', $lang);
return Redirect::back(); }
In the index function of the same controller it is:
public function index (Request $request)
{
\App::setLocale(\Session::get('lang'));
}
With this code Laravel is able to translate the strings. It works like a charm in my local PC, but when I install in a shared hosting server (in my case, Hostgator), it doesn't work. When I click on the webpage to switch to another language, it's just refreshing the page and the same original language shows. Why does this happen? What do I have to do for this to work in a shared hosting? Is that a kind of protection Laravel has?
For more details, session seems to be working OK, I print before executing the Lang::get in the views
\Log::info("Get Locale in Home page: ".\App::getLocale());
and it prints correctly to the language that I have just switched to, b
but then the {!! Lang::get('xxx') !!}
doesn't work, nor the {{ trans('xxx') }}
Languages files are well placed and everything works locally, but not in the shared hosting server.
So it is the Lang::get that doesn't get the appropiate language.
Any help will be welcomed,
Ariel