Fetch the default translation if the current locale doesn't have any translated attributes yet. In the example below the current article doesn't have have the title attribute translated to Swedish yet.
App::setLocale('en');
echo $article->title; // return 'Five Ants Are More than Four Elephants'
App::setLocale('sv');
echo $article->title; // returns 'Five Ants Are More than Four Elephants'
This can be turned off/on in the config.php file.
Add support to fetch a specific translation with the translate method.
$article->translate('sv')->title;
This release renames the configuration property from key to column.
This version is rewritten from the ground up. The session driver is removed and the documentation is updated.
This is a bugfix release. The locales migration used increment instead of increments.
This example migration comes out of the box with this package. Run the command below to add it to your projects database.
php artisan migrate --package="vinkla/translator"
It is now possible to save translated attributes on the base model. In the example below title and content are translateable attributes. The image attribute exists on the base model.
$title = 'Goa gubbar från Göteborg';
$content = 'Brödtext översatt på svenska.';
$image = 'weird-cat.jpg';
$article->update(compact('title', 'content', 'image'));
The translator package can now identify translateable attributes and save them in the current language. It compares fillable attributes with the translatedAttributes array that is set on our base model.
How can I help you explore Laravel packages today?