2017 © Pedro Peláez
 

library translate-that-model

This package adds a single trait to enable simple model translation.

image

mabasic/translate-that-model

This package adds a single trait to enable simple model translation.

  • Tuesday, July 1, 2014
  • by mabasic
  • Repository
  • 1 Watchers
  • 4 Stars
  • 26 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

TranslateThatModel

This package enables you to easily fetch localized columns from your models., (*1)

Requirements

  • You must have a table languages in your database
  • You must have a model for that table called Language

Installation

  1. Add "mabasic/translate-that-model": "1.0.*" to your composer require section and do composer update after that., (*2)

  2. Next, add Mabasic\TranslateThatModel\TranslateThatModelServiceProvider to your service_providers array in app.config., (*3)

  3. Publish config php artisan config:publish Mabasic/TranslateThatModel and edit config file with your model extension for translated models and language table column name for storing code (en, hr, it...)., (*4)

  4. Add use Mabasic\TranslateThatModel\TranslateThatModelTrait; in your models that require translation., (*5)

Usage

// get realestates and eager load city and nested relationship translations
$realestate = Realestate::with('city.translations')->get();

// display translated name on current application locale
{{ $realestate->city->translations->first()->name }}
//or 
// specify on which locale you want it returned
{{ $realestate->city->translations('hr')->first()->name }}

Info

If you have any questions or need more usage examples or features feel free to open a issue or contact me., (*6)

Credits

This package is inspired by laravel-translatable., (*7)

The reason why I could not just use the package above is that it assumes that I keep locale field in every table that holds translations. I keep locale field in my language table. After looking at the source code I concluded that It would be simpler to create my own package, because I don't need those fancy model update options., (*8)

The Versions

01/07 2014

dev-master

9999999-dev

This package adds a single trait to enable simple model translation.

  Sources   Download

MIT

The Requires

 

laravel trait model translation localization translate

29/06 2014

1.0.2

1.0.2.0

This package adds a single trait to enable simple model translation.

  Sources   Download

MIT

The Requires

 

laravel trait model translation localization translate

29/06 2014

1.0.1

1.0.1.0

This package adds a single trait to enable simple model translation.

  Sources   Download

MIT

The Requires

 

laravel trait model translation localization translate

29/06 2014

1.0.0

1.0.0.0

This package adds a single trait to enable simple model translation.

  Sources   Download

MIT

The Requires

 

laravel trait model translation localization translate