2017 © Pedro Peláez
 

library localizable

The localization plugin for laravel framework

image

riseno/localizable

The localization plugin for laravel framework

  • Thursday, October 20, 2016
  • by ryanchan.tc
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,375 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Laravel Localizable

Latest Stable Version Total Downloads License, (*1)

A small plugin for managing multi-language in database table., (*2)

Installation

Require this package with composer using the following command:, (*3)

composer require riseno/localizable

After updating composer, add the service provider to the providers array in config/app.php, (*4)

Riseno\Localizable\LocalizableServiceProvider::class,

Run artisan command to generate the database migration file, (*5)

php artisan riseno:localizable:generate user

After generated migration file, open the migration file. Add any column that should be localized., (*6)

Schema::create('user_localizations', function(Blueprint $table)
{
    $table->increments('id');
    $table->unsignedInteger('user_id');
    $table->string('locale');
    $table->boolean('default')->default(false);
    $table->string('name')->nullable();
    $table->timestamps();
    $table->foreign('user_id')->references('id')->on('users');
});

Once all the columns is added to migration file, run migrate command, (*7)

php artisan migrate

Go to the model that you want to implement localizable function, and add this trait to the class, (*8)

use Riseno\Localizable\LocalizableTrait;

class User extends Authenticatable
{
    use LocalizableTrait;

And also two required properties, (*9)

protected $localizeModel  = UserLocalizations::class;
protected $localizeFields = ['name'];

One more thing, add a localizations method, (*10)

public function localizations()
{
    return $this->hasMany(UserLocalizations::class, 'user_id', 'id');
}

Usage

The trait has provided a generic method for accessing the localized data,, (*11)

$user->localize('en_US');
// or access value directly
$user->localize('en_US')->name;

If you want to save / update the localized record, (*12)

$user->saveLocalize('en_US', ['name' => 'Riseno']);

License

The Laravel Localizable is open-sourced software licensed under the MIT license, (*13)

The Versions

20/10 2016

dev-master

9999999-dev

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

20/10 2016

dev-analysis-zE5v0y

dev-analysis-zE5v0y

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

12/02 2016

v1.1.1

1.1.1.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

12/02 2016

v1.1.0

1.1.0.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

12/02 2016

v1.0.3

1.0.3.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

12/02 2016

v1.0.2

1.0.2.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

12/02 2016

v1.0.1

1.0.1.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi

28/12 2015

v1.0.0

1.0.0.0

The localization plugin for laravel framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by RyanChan

laravel language eloquent localization multi