chinleung / laravel-locales
Add configurations and helpers for a multi locale application.
Installs: 111 606
Dependents: 3
Suggesters: 0
Security: 0
Stars: 35
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^8.0|^8.1
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.0
README
Add configurations and helpers to make an application support multiple locales.
Installation
You can install the package via composer:
composer require chinleung/laravel-locales
Configuration
By default, the application locales is only going to be en
. If your application support other locales, you can either set a app.locales
in your config/app.php
or publish the configuration file:
php artisan vendor:publish --provider="ChinLeung\LaravelLocales\LaravelLocalesServiceProvider" --tag="config"
Helpers
locale(string $locale = null) : string
Retrieve or update the current locale of the application.
// Alias of app()->getLocale(); locale(); // 'en' // Alias of app()->setLocale('fr'); locale('fr'); // 'fr' locale(); // 'fr'
locales(array $locales = null) : array
Retrieve or update the supported locales of the application.
Has priority forapp.locales
overlaravel-locales.supported
.
locales(); // ['en'] locales(['en', 'fr', 'zh']); locales(); // ['en', 'fr', 'zh'] locales(['en', 'zh']); locales(); // ['en', 'zh']
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email hello@chinleung.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.