LaravelPackages.net
Acme Inc.
Toggle sidebar
j-hansol/laravel-language-detect

This is a package for language detection and configuration for Laravel.

13
0
v1.0.0
About j-hansol/laravel-language-detect

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

Language detection and Setting for Laravel

License License

It provides a very simple function for detecting and setting the language in a website or backend service running on the Laravel framework.

installation

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

How to use

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');
});

Customize your preferences file

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
Comments