j-hansol/laravel-language-detect

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

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/j-hansol/laravel-language-detect

v1.0.0 2024-06-10 18:52 UTC

This package is auto-updated.

Last update: 2025-12-10 21:58:50 UTC


README

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