PHP code example of laraeast / laravel-locales
1. Go to this page and download the library: Download laraeast/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/ */
laraeast / laravel-locales example snippets
Laraeast\LaravelLocales\Providers\LocalesServiceProvider::class,
'Locales' => Laraeast\LaravelLocales\Facades\Locales::class,
Locales::get();
// array of supported locales
Locales::set('en');
Locales::current();
// the current locale instance
Locales::current()->getCode();
// or
Locales::getCode();
// return : en
Locales::current()->getName();
// or
Locales::getName();
// return : English
Locales::current()->getName();
// or
Locales::getDir();
// return : ltr
Locales::current()->getSvgFlag();
// or
Locales::getSvgFlag();
// return : svg (html)
Locales::from('en');
// return : \Laraeast\LaravelLocales\Enums\Language::EN
Locales::codes();
// return array of configured languages codes: ['en', 'ar', 'fr'. '...etc']
Locales::names();
// return array of configured languages names: ['English', 'العربية', 'Français'. '...etc']
Locales::flags(width: 30, height: 30);
// return array of configured languages svg flags with width=30 and height=30
bash
php artisan vendor:publish --tag="locales:config"
shell
php artisan locales:generate-js