Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Translatable

Laravel Translatable Laravel Package

dimsav/laravel-translatable

Add multi-language support to any Eloquent model without touching your schema. laravel-translatable stores translations in a dedicated table and lets you read, write, and fall back between locales using familiar Eloquent syntax, making it ideal for multilingual apps and APIs.

View on GitHub
Deep Wiki
Context7

dimsav/laravel-translatable is an Eloquent extension for Laravel that lets you store and manage multilingual model attributes without duplicating business logic. Define translatable fields once and retrieve or set them per locale, with translations persisted in a dedicated translations table.

  • Eloquent integration: transparent accessors and mutators for translated attributes.
  • Locale-aware retrieval: get and set values by locale with automatic fallback.
  • Flexible schema: per-locale translation rows in a separate table.
  • Query support: filter and sort models by translated fields.
  • Simple configuration: model trait and Laravel-friendly setup.
Frequently asked questions about Laravel Translatable
Is dimsav/laravel-translatable still maintained or deprecated?
Yes, dimsav/laravel-translatable is deprecated and archived upstream. There are no security patches, no PHP or Laravel compatibility work, and no issue triage. For modern Laravel projects the realistic path is package substitution, not adoption.
How do I install dimsav/laravel-translatable in a Laravel application?
On a period-appropriate Laravel 5.x stack you install it with composer require dimsav/laravel-translatable, publish the config, and add the Translatable trait plus a $translatedAttributes array to each model. You then create a translation table migration with a foreign key to the parent table, an indexed locale column, and a unique composite on parent_id and locale. On Laravel 8+ or PHP 8.1+ Composer resolution will fail without a fork, a version alias, or --ignore-platform-reqs workarounds that push risk downstream.
Which Laravel and PHP versions does dimsav/laravel-translatable support?
The 2019 release constrains Laravel 5.x-era and PHP 7.x-era dependencies. It is effectively not installable as-is on a modern Laravel baseline such as Laravel 10 or 11 with PHP 8.1+. Confirm your current and 12-month baseline before considering it; if Laravel 10 or 11 is on the roadmap, the archived package is disqualified outright.
How do I make an Eloquent model translatable with a $translatable or $translatedAttributes property?
Use the Translatable trait on the Eloquent model and list the locale-aware attributes in the protected $translatedAttributes array. Translations are stored in a separate table and accessed through the parent model, so $post->name returns the value for the current locale with fallback support. The package overview refers to a $translatable property, but the trait contract is built around $translatedAttributes.
How does locale fallback work in dimsav/laravel-translatable?
When a translated attribute is missing for the active locale, the package falls back to the configured default locale instead of erroring. This is convenient in development but dangerous in production because it can ship mislabeled content and create duplicate-language SEO pages. Treat silent fallback as an explicit product decision and decide whether your API or UI needs an explicit translation-missing state.
What database schema does dimsav/laravel-translatable use for translations?
It uses a normalized translation side-table design, for example posts plus post_translations, rather than a JSON column on the parent table. Each translated model adds a table and a join, with rows keyed by parent ID and locale; a unique composite on parent_id and locale is the usual constraint. Retrofitting indexes or locale-scoped slug uniqueness after data exists becomes a migration with data-repair work.
How do I query translations by locale, such as whereTranslation('slug', ...)?
The package supports locale-aware lookups such as whereTranslation('slug', $slug) and locale-scoped listing pages, which is the main advantage of the translation-table design. Because translated columns live in the side table, you can index per-locale slugs and metadata for SEO and unique constraints. This is a stronger fit than JSON columns when translations must be queried and indexed per locale.
What is the maintained alternative or fork for dimsav/laravel-translatable?
The maintained successor is astrotomic/laravel-translatable, a near drop-in fork with the same trait semantics. If you prefer JSON-column storage to avoid schema sprawl, spatie/laravel-translatable is the common alternative. Choose based on whether you need per-locale indexable columns and locale-scoped queries or simpler schema management.
How should I validate and test per-locale translated fields in Laravel?
Per-locale required fields leak into controllers, form requests, and validation rules, so define rules for nested keys such as en.name and ar.name or loop over the supported locales. In tests, create factory states for each locale and assert both the translated value and the fallback behavior explicitly. If silent fallback is unacceptable, add tests that require a translation-missing state instead of defaulting to the fallback language.
What are the production risks of adopting a deprecated Laravel translation package?
The highest-severity risk is an archived upstream: no security patches, no PHP or Laravel compatibility work, and no issue triage, so any transitive CVE or future PHP deprecation becomes yours to fix. Adopting it also means your fork becomes the de facto upstream, which is a standing maintenance tax unless you deliberately vendor a pinned copy. Schema sprawl and silent fallback add product risk, especially for SEO-sensitive multilingual content.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core