This is a package for language detection and configuration for Laravel.
j-hansol/laravel-language-detect is a Laravel package for this is a package for language detection and configuration for laravel..
It currently has 0 GitHub stars and 13 downloads on Packagist (latest version v1.0.0).
Install it with composer require j-hansol/laravel-language-detect.
Discover more Laravel packages by j-hansol
or browse all Laravel packages to compare alternatives.
Last updated
It provides a very simple function for detecting and setting the language in a website or backend service running on the Laravel framework.
You can simply install it with the command below from the project path under development.
composer require j-hansol/laravel-language-detect
Add the following content to the .env file. If not added, it will be set to the contents of the language_detect.php file included in the package.
APP_LOCALES="ko,en"
APP_LOCALE_SEGMENT=1
APP_LOCALE_FIELD_NAME=language
To detect and set the language, simply add middleware to the routing path as shown below.
Route::prefix('{locale}')->group(function() {
Route::get('test', [\App\Http\Controllers\LanguageSettingTest::class, 'showResult'])
->middleware('set_language');
});
If you have made the necessary settings in .env, this step will not be necessary. Nevertheless, if you want to change the settings, you can change the contents after executing the command below.
php artisan vendor:publish --tag=language-detect