Simple subdomain localization for Laravel.
Simplified localization for Laravel based on the application's subdomain.
- Determining Locale
- Localization on Packagist
- Localization on GitHub
From the command line run:
$ composer require torann/localization
Once installed you need to register the service provider with the application. Open up
config/app.php and find the
'providers' => [ \Torann\Localization\LocalizationServiceProvider::class, ]
Run this on the command line from the root of your project:
php artisan vendor:publish --provider="Torann\Localization\LocalizationServiceProvider"
A configuration file will be publish to
The following methods are available:
- getNonLocalizedURL($url = null)
- setLocale($locale = null)
- localizeURL($locale = null, $url = null)
- getLocalizedURL($locale = null, $url = null, $attributes = )
- getConfig($key, $default = null)
Laravel Localization comes with a few helper methods
Returns the given URL adapted to provided locale.
For this to work the subdomain needs to match an enabled supported locale key.
When the given subdomain is determined to not be valid the system can then set the locale depending on the current host. You'll need to set a map of your application's locales to hosts using the hosts configuration option.
Localization is open-sourced software licensed under the BSD 2-Clause License.