PHP code example of elnooronline / laravel-locales

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

    

elnooronline / laravel-locales example snippets


    Elnooronline\LaravelLocales\Providers\LocalesServiceProvider::class,
    

    'Locales' => Elnooronline\LaravelLocales\Facades\Locales::class,
    

Locales::get();
// array of supported locales

Locales::set('en');

Locales::current();
// the current locale instance

Locales::current()->code;
// or 
Locales::getCode();
// return : en

Locales::current()->name;
// or 
Locales::getName();
// return : English

Locales::current()->dir;
// or
Locales::getDir();
// return : ltr

Locales::current()->flag;
// or
Locales::getFlag();
// return : /images/flages/us.png
bash
    php artisan vendor:publish --tag="locales:config"
    
bash
    php artisan vendor:publish --tag="locales:flags"