1. Go to this page and download the library: Download d3jn/laravel-languages 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/ */
Languages::setLocaleCallable(function ($locale) {
// Example of initializing various packages with locale:
Carbon::setLocale($locale);
LaravelGettext::setLocale($locale);
App::setLocale(LaravelGettext::getLocaleLanguage());
});
Route::group(
['prefix' => Languages::init(), 'middleware' => ['languages']],
function () {
Route::get('/', function () {
return __('hello');
});
...
}
);