PHP code example of d3jn / laravel-languages

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

    

d3jn / laravel-languages example snippets


'providers' => [
    ...

    D3jn\LaravelLanguages\LanguagesServiceProvider::class,

    ...
],

...

'aliases' => [
    ...

    'Languages' => D3jn\LaravelLanguages\Facades\Languages::class,

    ...
],

Languages::setLocaleCallable(function ($locale) {
    // Example of initializing various packages with locale:
    Carbon::setLocale($locale);
    LaravelGettext::setLocale($locale);
    App::setLocale(LaravelGettext::getLocaleLanguage());
});

Route::group(
    ['prefix' => Languages::init(), 'middleware' => ['languages']],
    function () {
        Route::get('/', function () {
            return __('hello');
        });

        ...
    }
);
app.php

php artisan vendor:publish --provider="D3jn\LaravelLanguages\LanguagesServiceProvider"
config/languages.php