Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/divineomega/laravel-domain-to-locale
Change your Laravel app's locale based on the domain name
https://github.com/divineomega/laravel-domain-to-locale
i18n internationalization laravel-5-package locale
Last synced: 19 days ago
JSON representation
Change your Laravel app's locale based on the domain name
- Host: GitHub
- URL: https://github.com/divineomega/laravel-domain-to-locale
- Owner: DivineOmega
- License: lgpl-3.0
- Created: 2019-05-13T11:01:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-23T09:39:06.000Z (over 5 years ago)
- Last Synced: 2024-10-15T02:39:15.720Z (about 1 month ago)
- Topics: i18n, internationalization, laravel-5-package, locale
- Language: PHP
- Size: 9.77 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Domain To Locale
Change your Laravel app's locale based on the domain name.
## Installation
To install the Laravel Domain To Locale package, just run
the following Composer command from the root of your
project.```bash
composer require divineomega/laravel-domain-to-locale
```## Setup
This package requires you to register a global middleware
within your `app\Http\Kernel.php` file. Just add the
line below to your `$middleware` array.```php
\DivineOmega\LaravelDomainToLocale\Http\Middleware\DomainToLocale::class,
```After installation, the config file must be setup within
your project. To do so, simply run the following Artisan
command.```bash
php artisan vendor:publish --provider="DivineOmega\LaravelDomainToLocale\ServiceProvider"
```## Configuration
The published configuration file for this package
can be found at `config/domain-to-locale.php`.
This file defines a map between domain name and locale,
as shown in the example below.```php
['example.com' => 'en',
'example.co.uk' => 'en',
'example.pl' => 'pl',
'example.de' => 'de',
'example.fr' => 'fr',]
];
```Adding new lines to the `map` array will allow you to
specify which domain names should set which locales.
Once configured, everything else is automatic.