PHP code example of nascent-africa / laravel-locale

1. Go to this page and download the library: Download nascent-africa/laravel-locale 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/ */

    

nascent-africa / laravel-locale example snippets



namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use NascentAfrica\LaravelLocale\LaravelLocaleFacade;

class AppServiceProvider extends ServiceProvider
{

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        LaravelLocaleFacade::setLocales([
            'en', 'fr'
        ]);
    }
}

    ...
    
    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            ...
            NascentAfrica\LaravelLocale\Http\Middleware\LocaleMiddleware::class
        ],

        ...
    ];