Skip to content
A package for manipulating and saving Laravel Eloquent models in multiple languages
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Typo and grammar fixes Jul 2, 2019
migrations
src
stubs
tests Implement tests for the optional caching mechanism Apr 19, 2019
.gitignore Remove composer.lock from the package Mar 7, 2019
.scrutinizer.yml Initial commit for the release Mar 5, 2019
.styleci.yml Initial commit for the release Mar 5, 2019
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
composer.json

README.md

A robust yet elegant system for translating Eloquent Models

Latest Stable Version Software License Build Status Scrutinizer Code Quality

This package is meant to simplify the process of making Eloquent models translatable. It's aim is to deviate as little as possible from Laravel's Eloquent API but still provide a satisfiable level of flexibility. This is achieved by utilizing a driver-based approach to storing translations and a trait which allows Model instances to seamlessly interact with the translation storage.

After setting the package up, all that takes to use your models with translations is this:

$post = BlogPost::find(1); // An instance of the BlogPost model

App::setLocale('sr');
$post->title = 'Naslov na srpskom';
$post->save();

$post->setLanguage('en');
$post->title = 'Title in English';
$post->save();

$post->title; // Returns 'Title in English';
$post->setLanguage('sr')->title; // Returns 'Naslov na srpskom'

Since this is a driver-based solution, you have the full power to implement the architecture for persistently storing translations yourself. Of course, the package comes with two drivers out of the box, JSON and MySQL, but you are free to implement your own drivers and rely on whatever architecture you prefer.

For a more detailed explanation on how the package works and how to use it, please visit our wiki pages.

You can’t perform that action at this time.