2017 © Pedro Peláez
 

library tarjama

It's a laravel model columns translation manager

image

laravelarab/tarjama

It's a laravel model columns translation manager

  • Saturday, March 17, 2018
  • by chadidi
  • Repository
  • 3 Watchers
  • 29 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

this package is deprecated please use: https://github.com/fevrok/laravel-translatable, (*1)

tarjama

It's a Laravel model columns translation manager, (*2)

Current working model

Laravel Tarjama current working model, (*3)

Installation

You can install the package via composer:, (*4)

composer require laravelarab/tarjama

If you have Laravel 5.5 and up The package will automatically register itself., (*5)

else you have to add the service provider to app/config/app.php, (*6)

LaravelArab\Tarjama\TarjamaServiceProvider::class,

If you want to change the default locale, you must publish the config file:, (*7)

php artisan vendor:publish --provider="LaravelArab\Tarjama\TarjamaServiceProvider"

This is the contents of the published file:, (*8)

return [

   /**
    * Default Locale || Root columns locale
    * We will use this locale if config('app.locale') translation not exist
    */
   'locale' => 'en',

   /**
    * Supported Locales e.g: ['en', 'fr', 'ar']
    */
   'locales' => ['ar', 'en', 'fr']

];

next migrate translations table, (*9)

php artisan migrate

Making a model translatable

The required steps to make a model translatable are:, (*10)

  • Just use the LaravelArab\Tarjama\Translatable trait.

Here's an example of a prepared model:, (*11)

use Illuminate\Database\Eloquent\Model;
use LaravelArab\Tarjama\Translatable;

class Item extends Model
{
    use Translatable;

    /**
      * The attributes that are Translatable.
      *
      * @var array
      */
    protected $translatable = [
        'name', 'color'
    ];
}

Available methods

Saving translations, (*12)

$item = new Item;
$data = array('en' => 'car', 'ar' => 'سيارة');

$item->setTranslations('name', $data); // setTranslations($attribute, array $translations, $save = false)

// or save one translation
$item->setTranslation('name', 'en', 'car', true); // setTranslation($attribute, $locale, $value, $save = false)

// or just do
$item->name = 'car'; // note: this will save automaticaly unless it's the default locale

// This will save if (current locale == default locale OR $save = false)
$item->save();

Get translations, (*13)

$item = new Item::first();
// get current locale translation
$item->city
OR
$item->getTranslation('city');

// pass translation locales
$item->getTranslation('city', 'ar'); // getTranslation($attribute, $language = null, $fallback = true)
$item->getTranslationsOf('name', ['ar', 'en']); // getTranslationsOf($attribute, array $languages = null, $fallback = true)

Delete translations, (*14)

$item = new Item::first();
$item->deleteTranslations(['name', 'color'], ['ar', 'en']); // deleteTranslations(array $attributes, $locales = null)

Maintainers

Abdellah Chadidi

The Versions

17/03 2018

dev-master

9999999-dev https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

17/03 2018

v1.6.2

1.6.2.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

27/12 2017

v1.6.1

1.6.1.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

27/12 2017

v0.6.0

0.6.0.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

27/12 2017

v1.0.0

1.0.0.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

27/12 2017

v1.6.0

1.6.0.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

27/12 2017

v0.5.1

0.5.1.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

16/12 2017

v0.4.0

0.4.0.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

10/12 2017

v0.3.0

0.3.0.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

The Requires

 

The Development Requires

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

31/10 2017

v0.2.2

0.2.2.0 https://github.com/LaravelArab/tarjama

It's a laravel model columns translation manager

  Sources   Download

MIT

by Abdellah Chadidi

laravel eloquent model translation multilingual translate i8n laravel-package tarjama

31/10 2017

v0.2.1

0.2.1.0

It's a laravel model columns translation manager

  Sources   Download

MIT

by Abdellah Chadidi