I recommend to you use this package
Aug 10, 2020
3
Level 2
Localization Issues
I have a dual lingo website and I have a file in lang en for English and another folder for another language The English version works. Because in the view there is no English version its replaced with the arabic version in the ar folder. Basically from the header once you click the menu option of the other language then it should switch language. I just don't understand why it refuses to switch. Even if I change default locale to ar it still only reads en folder.
home.blade.php
{{__('home.thank.you')}}
lang/en/home.php
"thank.you" => "Thank You",
lang/ar/home.php
"thank.you" => "شكرا",
web.php
Route::get('/',['as' => 'site.home', 'uses' => 'BlogController@index'] ,function () {
if(Session::get('locale') == null){
Session::put('locale', 'en');
}
return view('pages.home');
});
BlogController.php
public function index()
{
if(Session::get('locale') == null)
{
Session::put('locale', 'en');
}
header.blade.php
<div class="dropdown">
<button class="fa fa-language"></button>
<div class="dropdown-content">
<a class="social-ln" href="locale/en" data-request="onSwitchLocale"
data-request-data="locale: 'en'">English</a>
<a class="social-ln" href="locale/ar" data-request="onSwitchLocale"
data-request-data="locale: 'ar'">عربى</a>
</div>
</div>
Level 75
Please or to participate in this conversation.