The package allows adding translations to your Eloquent models.
- Translatable attributes behave like regular model attributes.
- Full support for accessors, mutators and casts (even JSON).
- Fallback translations.
- 4 different strategies for storing translations.
$book = new Book()
$book->translator()->set('title', 'Fifty miles', 'en')
$book->translator()->set('title', "ะ'ััะดะตััั ะฒะตัััะพะฒ", 'uk')
$book->save();
app()->setLocale('en');
echo $book->title; // Fifty miles
app()->setLocale('uk');
echo $book->title; // ะ'ััะดะตััั ะฒะตัััะพะฒ
- PHP
7.2
or newer - Laravel
7.0
or newer - Can work with Octane
Install the package via composer:
composer require nevadskiy/laravel-translatable
Documentation for the package can be found in the Wiki section.
There is a small package for the Laravel Nova that adds support for translatable fields.
Please see CHANGELOG for more information what has changed recently.
Thank you for considering contributing. Please see CONTRIBUTING for more information.
The MIT License (MIT). Please see LICENSE for more information.