PHP code example of swayok / laravel-language-detector
1. Go to this page and download the library: Download swayok/laravel-language-detector 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/ */
swayok / laravel-language-detector example snippets
//That would be nice if you put (edit) it on your App\Providers\RouteServiceProvider.
// Laravel
Route::group(['prefix' => app('language.routePrefix'), 'namespace' => 'App\Http\Controllers'], function ($router) {
.php';
}
$prefix = app('language.routePrefix');
$options = [];
if (!empty($prefix) && $prefix!="/") {
$options['prefix'] = $prefix;
}
// any other options here
$options['namespace'] = 'App\Http\Controllers';
$app->group($options, function () use($app) {
// ...
});
'languages' => ['en', 'pt_BR' ...]
'languages' => [
'pt_BR' => 'pt-BR', //will detect pt_BR language, and set pt-BR to the application,
'pt' => 'pt-BR', //aliasing, will detect pt and set pt-BR to the application
'pt-br' => "pt-BR", //aliasing, will detect pt-br and set pt-BR to the application (you will need it with subdomain driver)
'en', //will detect 'en' language
]