Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Locales Laravel Package

chinleung/laravel-locales

Add multi-locale support to Laravel with simple config and helper functions. Define supported locales via app.locales or a published config, and use locale() to get/set the current locale and locales() to get/set supported locales.

View on GitHub
Deep Wiki
Context7

Laravel Locales

Latest Version on Packagist Build Status Quality Score Total Downloads

Add configurations and helpers to make an application support multiple locales.

Versions

Package Laravel PHP
3.x 13.x ^8.3
2.x 9.x–12.x ^8.0
1.x 6.x–8.x ^7.4

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 for app.locales over laravel-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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport