1. Go to this page and download the library: Download pmochine/laravel-tongue library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function boot()
{
// This will guess a locale from the current HTTP request
// and set the application locale.
tongue()->detect();
//If you use Carbon you can set the Locale right here.
\Carbon\Carbon::setLocale(tongue()->current());
parent::boot();
}
...
// Without the localize middleware, this route can be reached with or without language subdomain
Route::get('logout', 'AuthController@logout');
// With the localize middleware, this route cannot be reached without language subdomain
Route::group([ 'middleware' => [ 'speaks-tongue' ]], function() {
Route::get('welcome', 'WelcomeController@index');
});