Auto-Translated (Content-Based)
Install Google Translate API PHP Package
composer require stichoza/google-translate-php
Enter fullscreen mode
Exit fullscreen mode
Language Switcher (View)
<div class= "flex items-center space-x-2" > <a href= "/lang/id" class= "text-gray-200 hover:text-white {{ session('locale') === 'id' ? 'border-b-2 border-yellow-500' : '' }}" > ID </a> <span class= "text-gray-200" > | </span> <a href= "/lang/en" class= "text-gray-200 hover:text-white {{ session('locale') === 'en' || !session('locale') ? 'border-b-2 border-yellow-500' : '' }}" > EN </a> </div>
Enter fullscreen mode
Exit fullscreen mode
Route for Language Switching
Route :: get ( '/lang/{lang}' , function ( $lang ) { session ([ 'locale' => $lang ]); return back (); });
Enter fullscreen mode
Exit fullscreen mode
Migration β add columns to store translations:
Schema :: table ( 'abouts' , function ( Blueprint $table ) { $table -> string ( 'title' ); $table -> text ( 'description' ); $table -> json (β¦