|
| 1 | +# Additional information |
| 2 | + |
| 3 | +## Installation |
| 4 | + |
| 5 | +### For Laravel 5.4 and below: |
| 6 | + |
| 7 | +For older versions of the framework, follow the steps below: |
| 8 | + |
| 9 | +Register the service provider in `config/app.php` |
| 10 | + |
| 11 | +```php |
| 12 | + 'providers' => [ |
| 13 | + // [...] |
| 14 | + Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class, |
| 15 | + ], |
| 16 | +``` |
| 17 | + |
| 18 | +You may also register the `LaravelLocalization` facade: |
| 19 | + |
| 20 | +```php |
| 21 | + 'aliases' => [ |
| 22 | + // [...] |
| 23 | + 'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class, |
| 24 | + ], |
| 25 | +``` |
| 26 | + |
| 27 | +## Config |
| 28 | + |
| 29 | +### Service Providers |
| 30 | + |
| 31 | +Otherwise, you can use `ConfigServiceProviders` (check <a href="https://raw.githubusercontent.com/mcamara/laravel-localization/master/src/config/config.php">this file</a> for more info). |
| 32 | + |
| 33 | +For example, editing the default config service provider that Laravel loads when it's installed. This file is placed in `app/providers/ConfigServicePovider.php` and would look like this: |
| 34 | + |
| 35 | +```php |
| 36 | +<?php namespace App\Providers; |
| 37 | + |
| 38 | +use Illuminate\Support\ServiceProvider; |
| 39 | + |
| 40 | +class ConfigServiceProvider extends ServiceProvider { |
| 41 | + public function register() |
| 42 | + { |
| 43 | + config([ |
| 44 | + 'laravellocalization.supportedLocales' => [ |
| 45 | + 'ace' => array( 'name' => 'Achinese', 'script' => 'Latn', 'native' => 'Aceh' ), |
| 46 | + 'ca' => array( 'name' => 'Catalan', 'script' => 'Latn', 'native' => 'català' ), |
| 47 | + 'en' => array( 'name' => 'English', 'script' => 'Latn', 'native' => 'English' ), |
| 48 | + ], |
| 49 | + |
| 50 | + 'laravellocalization.useAcceptLanguageHeader' => true, |
| 51 | + |
| 52 | + 'laravellocalization.hideDefaultLocaleInURL' => true |
| 53 | + ]); |
| 54 | + } |
| 55 | + |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +This config would add Catalan and Achinese as languages and override any other previous supported locales and all the other options in the package. |
| 60 | + |
| 61 | +You can create your own config providers and add them on your application config file (check the providers array in `config/app.php`). |
0 commit comments