PHP code example of cheecodes / language-detection

1. Go to this page and download the library: Download cheecodes/language-detection 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/ */

    

cheecodes / language-detection example snippets


protected $middleware = [
        // ...
        DetectLanguage::class,
        // ...
    ];

protected $routeMiddleware = [
    // ...
    'language' => DetectLanguage::class,
    // ...
];

'loaders'   => [
    // Default group
    'default' => [
        FromHeader::class,
        FromQueryParameter::class,
        FromSession::class,
        FromCookie::class,
    ],
    // custom group
    'custom' => [
        FromHeader::class,
    ]
],

Route::group('/admin', function() {
    // Your routes go here
})->middleware('language:custom'); // Changing the loader stack to "custom"

public function load(Request $request, array $config): ?string

'loaders' => [
    'default' => [
        // ...
        Acme\Loaders\MyCustomLoader::class,    
    ]
];
bash
php artisan vendor:publish