2017 © Pedro Peláez
 

library laravel-i18n

Simple route and eloquent localization / translation in Laravel

image

richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

  • Saturday, July 21, 2018
  • by richan-fongdasen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 223 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build codecov StyleCI Analysis Status Total Downloads Latest Stable Version License: MIT, (*1)

Laravel I18n

Simple Route localization and Eloquent translation in Laravel, (*2)

Synopsis

This package provides easy ways to setup database translation and route localization., (*3)

Table of contents

Setup

Install the package via Composer :, (*4)

$ composer require richan-fongdasen/laravel-i18n

Publish package assets

Publish the package asset files using this php artisan command, (*5)

$ php artisan vendor:publish --provider="RichanFongdasen\I18n\ServiceProvider"

The command above would create three new files in your application, such as:, (*6)

  • New configuration file /config/i18n.php
  • New database migration /database/migrations/0000_00_00_000000_create_languages_table.php
  • New languages json file /storage/i18n/languages.json

Configuration

return [

    /*
    |--------------------------------------------------------------------------
    | Language repository driver
    |--------------------------------------------------------------------------
    |
    | Define your language repository driver here. The available options are:
    | database and json.
    |
    */

    'driver' => 'json',

    /*
    |--------------------------------------------------------------------------
    | Language repository datasource
    |--------------------------------------------------------------------------
    |
    | Define your language repository datasource here.
    |   - Define your database table name, when you're using database driver.
    |   - Define your json file path, when you're using json driver.
    |
    */

    'language_datasource' => storage_path('i18n/languages.json'),
//    'language_datasource' => 'languages',

    /*
    |--------------------------------------------------------------------------
    | Cache duration
    |--------------------------------------------------------------------------
    |
    | Define how long we should cache the language dataset in seconds.
    |
    */

    'cache_duration' => 60 * 60 * 24,

    /*
    |--------------------------------------------------------------------------
    | Language key
    |--------------------------------------------------------------------------
    |
    | Define which language key in datasource that we should use.
    | Available options are:
    |   - language, ie: en, es, de, etc.
    |   - ietfCode, ie: en-US, en-UK, de-DE, etc.
    |
    */

    'language_key' => 'language',

    /*
    |--------------------------------------------------------------------------
    | API query key
    |--------------------------------------------------------------------------
    |
    | Define the query parameter name which will be used as language selector
    | in every API request.
    | e.g: http://localhost:8000/api/articles?lang=en
    |
    */

    'api_query_key' => 'lang',

    /*
    |--------------------------------------------------------------------------
    | Language negotiator class
    |--------------------------------------------------------------------------
    |
    | Define your language negotiator class here.
    | The class should implement LanguageNegotiator contract / interface.
    |
    */

    'negotiator' => \RichanFongdasen\I18n\Negotiators\BrowserNegotiator::class,

    /*
    |--------------------------------------------------------------------------
    | Locale URL segment number
    |--------------------------------------------------------------------------
    |
    | Define which url segment number that will be used to put the current
    | locale information. URL segment is started with '1'.
    | e.g: http://my-application.app/en/home
    |
    */

    'locale_url_segment' => 1,

    /*
    |--------------------------------------------------------------------------
    | Translation table suffix
    |--------------------------------------------------------------------------
    |
    | Define your preferred suffix to be appended to your database's
    | translation table name.
    |
    */

    'translation_table_suffix' => 'translations',

    /*
    |--------------------------------------------------------------------------
    | Enable Store to the cache
    |--------------------------------------------------------------------------
    |
    | Toggle store locale to the cache
    |
    */

    'enable_cache' => env('I18N_ENABLE_CACHE', true),

];

Documentation

Please check the documentation here https://laravel-i18n.richan.id/, (*7)

Credits

  • mcamara/laravel-localization - Route localization concepts in this repository was inspired by this package.
  • Wico Chandra - Database translation concepts in this repository was inspired by his Model Translation concept.
  • dimsav/laravel-translatable - Some of database translation concepts in this repository was inspired by this package.

License

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

The Versions

21/07 2018

dev-master

9999999-dev https://github.com/richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Richan Fongdasen

laravel eloquent translation i18n internationalization localization routes intl laravel-5-package laravel-routes

16/06 2018

dev-laravel-5.1

dev-laravel-5.1 https://github.com/richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Richan Fongdasen

laravel eloquent translation i18n internationalization localization routes intl laravel-5-package laravel-routes

16/06 2018

1.1.0

1.1.0.0 https://github.com/richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Richan Fongdasen

laravel eloquent translation i18n internationalization localization routes intl laravel-5-package laravel-routes

05/06 2018

1.0.0

1.0.0.0 https://github.com/richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Richan Fongdasen

laravel eloquent translation i18n internationalization localization routes intl laravel-5-package laravel-routes