2017 © Pedro Peláez
 

library languageintegration

The package introduces dynamic language change capability for a laravel instance.

image

danieldoinov/languageintegration

The package introduces dynamic language change capability for a laravel instance.

  • Friday, November 3, 2017
  • by danieldoinov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Language Integration

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Provides functionality to dynamically change a Laravel current locale. Basically makes laravel multilingial from a users stand point., (*2)

Install

Via Composer, (*3)

``` bash $ composer require danieldoinov/languageintegration, (*4)


This package has integrated geo-location that uses the following package ``Stevebauman\Location`` It should be installed automatically with this one but just in case that it isn't you can install it by running ```php composer require stevebauman/location

You must add the providers in config/app.php, (*5)

``` php Stevebauman\Location\LocationServiceProvider::class, DanielDoinov\LanguageIntegration\LanguageIntegrationServiceProvider::class, (*6)

You can then publish the configuration files.

``` php
php artisan vendor:publish --provider="danieldoinov\LanguageIntegration\LanguageIntegrationProvider"
php artisan vendor:publish --provider="Stevebauman\Location\LocationServiceProvider"

Usage

What the package does is add one route and one middleware that handle the locale change. out of the box it will give you the following options for changing the locale:, (*7)

```php http://yourdomain.com/locale/[lang], (*8)

Linking to that url will change the applications locale to the one that you specified. The ```[lang]``` variable must a valid locale code and must be present in the ```config/languages.php``` configuration file. After the change of locale the route will redirect back with any other input present. 

You can create links that change the locale dynamically my adding a ```?lang=[lang]``` to any route in you application. 

The first time the application starts the middleware will look for a cookie with a preferred locale. If none is found it will geo-locate the user and switch to the configured locale based on country code. 

You can configure all of that from   ```config/languages.php``` as well as cookie name and route format. 

Here is the default full configuration: 

```php
    'cookie_key' => 'current_locale',     
    'locale' => [
        'en' => 'English',
        'de' => 'Deutsche',
        'es' => 'Español',
        'ru' => 'Русский'
    ],
    'country_code_to_locale' => [
        'US' => 'en',
        'GB' => 'en',
        'CA' => 'en',
        'UM' => 'en',
         //spanish
        'ES' => 'es',
         //german
        'DE' => 'de',
         //Russion
        'RU' => 'ru',
    ],    
    'route' => '/locale/{lang}',
    'route_name' => 'setLocale'

Hope you like it and helps!, (*9)

Credits

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

03/11 2017

dev-master

9999999-dev https://github.com/DanielDoinov/LanguageIntegration

The package introduces dynamic language change capability for a laravel instance.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel multilingual danieldoinov languageintegration language support