2017 © Pedro Peláez
 

library laravel-i18n

Laravel internationalization package

image

webnuvola/laravel-i18n

Laravel internationalization package

  • Thursday, June 7, 2018
  • by fab120
  • Repository
  • 1 Watchers
  • 0 Stars
  • 367 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 58 % Grown

The README.md

Laravel Internationalization

Latest Version on Packagist, (*1)

This package allows you to split your website into multiple regions with route translation support., (*2)

Attention: until version 1.0.0, this package must be considered unstable. Use it carefully., (*3)

Installation

This package supports only laravel 5.5 and you can install via composer:, (*4)

``` bash composer require webnuvola/laravel-i18n, (*5)


The service provider and the facade `I18nRouter` will automatically get registered. After the installation, you must publish the config file and set it up to your needs. ```bash php artisan vendor:publish --provider="Webnuvola\Laravel\I18n\I18nServiceProvider" --tag="config"

Configuration

You must configure at least one region before moving to the usage step., (*6)

When published, the config/i18n.php config file contains:, (*7)

return [

    /*
    |--------------------------------------------------------------------------
    | Available regions
    |--------------------------------------------------------------------------
    |
    | List of languages and countries to view your site in the format {language}-{country}.
    | Available languages: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
    | Available countries: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
    | Examples: en-us, en-gb, it-it, ...
    |
    */

    'regions' => [
        //
    ],

    /*
    |--------------------------------------------------------------------------
    | Default region
    |--------------------------------------------------------------------------
    |
    | The default region will be accessible without any prefix to uris.
    | Set this value to a region (e.g. en-us) or to null to disable
    | the behaviour.
    |
    */

    'default' => null,

];

Usage

Open your routes/web.php file and replace Route with I18nRoute., (*8)

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

I18nRoute::get('/', function () {
    return view('welcome');
});

I18nRoute::get('test', 'TestController@test');

This package will register routes for the regions in the configuration file., (*9)

Helper functions like url() and route() will automatically generate the correct url based on the request., (*10)

Route Translation

This package allows you to translate routes using the Laravel translator service. You just need to insert the translation key between square brackets., (*11)

For example with this i18n.php config file:, (*12)

[
    'regions' => [
        'en-us',
        'fr-fr',
        'it-it',
    ],

    'default' => 'en-us',
]

and this web.php file:, (*13)

I18nRoute::get('[routes.product]/{id}', 'ProductController@show');

this routes will be generated:, (*14)

/product/{id}
/fr-fr/produit/{id}
/it-it/prodotto/{id}

Cache

We strongly recommend to cache routes by running php artisan route:cache in your production environment. This package adds a layer of complexity everytime routes have to be parsed., (*15)

Known Issues

  • Helper function action() does not return the correct url
  • Tests for this package are still missing

Changelog

Please see CHANGELOG for more information what has changed recently., (*16)

Contributing

CONTRIBUTING guidelines will be published soon., (*17)

Security

If you discover any security-related issues, please email fabio@webnuvola.com instead of using the issue tracker., (*18)

Credits

License

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

The Versions

07/06 2018

dev-master

9999999-dev

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

07/06 2018

v0.1.11

0.1.11.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

07/06 2018

v0.1.10

0.1.10.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

21/03 2018

v0.1.9

0.1.9.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

30/01 2018

v0.1.8

0.1.8.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

30/01 2018

v0.1.7

0.1.7.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

29/01 2018

v0.1.6

0.1.6.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

26/01 2018

v0.1.5

0.1.5.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

25/01 2018

v0.1.4

0.1.4.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

25/01 2018

v0.1.3

0.1.3.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

25/01 2018

v0.1.2

0.1.2.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

24/01 2018

v0.1.1

0.1.1.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel php translation i18n internationalization localization

24/01 2018

v0.1.0

0.1.0.0

Laravel internationalization package

  Sources   Download

MIT

The Requires

 

by Fabio Cagliero

laravel language i18n internationalization localization multi-language language-selector