pharaonic / laravel-translatable
Translated fields for Laravel Eloquent models in three storage strategies behind one API: a translations table, a JSON column per field, or a column per locale.
13.0.2
2026-11-19 21:48 UTC
Requires
- php: >=8.3 <8.6
- illuminate/console: ^13.0
- illuminate/contracts: ^13.0
- illuminate/database: ^13.0
- illuminate/filesystem: ^13.0
- illuminate/http: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- laravel/pint: ^1.20
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1.33
- phpunit/phpunit: ^12.5.8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-19 21:55:53 UTC
README
Translated Eloquent fields in three storage strategies, a translations table, a JSON column per field or a column per locale, behind one API.
Installation
composer require pharaonic/laravel-translatable
The service provider is registered automatically. Publish the configuration when you need to change it:
php artisan vendor:publish --tag=translatable-config
Usage
use Illuminate\Database\Eloquent\Model; use Pharaonic\Laravel\Translatable\Contracts\JsonTranslatable; use Pharaonic\Laravel\Translatable\Translatable; class Post extends Model implements JsonTranslatable // or TableTranslatable, ColumnsTranslatable, or none for the default { use Translatable; protected $translatables = ['title', 'body']; } $post = new Post; $post->setTranslation('title', 'en', 'Hello')->setTranslation('title', 'ar', 'مرحبا')->save(); $post->title; // the current locale, with the fallback locale when missing $post->getTranslation('title', 'ar'); // exactly what is stored for Arabic, or null Post::whereTranslation('title', 'Hello', 'en')->get();
Documentation
Full documentation: Laravel Translatable Documentation.
Support & Security
See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.
License
MIT. See LICENSE.
