Download the PHP package sinkcup/laravel-locale-setter without Composer
On this page you can find all versions of the php package sinkcup/laravel-locale-setter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sinkcup/laravel-locale-setter
More information about sinkcup/laravel-locale-setter
Files in sinkcup/laravel-locale-setter
Package laravel-locale-setter
Short Description detect Accept-Language, setLocale, then you can use Laravel localization
License MIT
Informations about the package laravel-locale-setter
Laravel Locale Setter Middleware
This package detect Accept-Language in HTTP header(query string and cookie will be comming), setLocale, then you can use Laravel localization for I18N.
Installation
Install the package via Composer:
Next, add the package's service provider to your config/app.php
:
and then you'll just need to publish the package's configuration:
which will create config/locale.php
.
Usage
Global Middleware
Normally, it should run during every HTTP request, simply add the middleware class to the $middleware property of your app/Http/Kernel.php
class. For example:
Assigning Middleware To Routes
if you would like to assign middleware to specific routes, you should add the middleware class to the $routeMiddleware property of your app/Http/Kernel.php
class. For example:
Once the middleware has been defined in the HTTP kernel, you may use the middleware method to assign middleware to a route:
Config
Linux locale and HTML 4 language code followed RFC1766 which was released at March 1995. It's out-of-date.
Due to historical reasons, Linux locale and browsers are still using old standard at now.
iOS want to change it, use zh-Hans and zh-Hans-CN, but it's wrong too.
If you want to do something right, follow the modern standard - BCP47 which HTML5 using, and map old language codes to new.
You should use cmn-Hans, cmn-Hans-CN, cmn-Hant and cmn-Hant-TW, instead of zh-CN, zh-TW, zh-Hans and zh-Hant.
create dirs:
then use:
If you care about regional differences, create dirs:
then use: