Download the PHP package flobbos/laravel-translatable-db without Composer
On this page you can find all versions of the php package flobbos/laravel-translatable-db. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download flobbos/laravel-translatable-db
More information about flobbos/laravel-translatable-db
Files in flobbos/laravel-translatable-db
Package laravel-translatable-db
Short Description A Laravel package for multilingual models
License MIT
Informations about the package laravel-translatable-db
Laravel Translatable DB
Database-backed translated Eloquent attributes, resolved by a language id instead of a locale string.
This package started as a fork of dimsav/laravel-translatable. It only reads translated attributes. It does not manage CRUD forms or translation persistence.
Compatibility
| Laravel | Package |
|---|---|
| 13.x | 2.x |
| 12.x | 2.x |
| 11.x | 2.x |
| 10.x | 2.x |
| 5.3-9.x | 1.x |
Laravel 10 support means the package requires PHP ^8.1. Laravel itself may require a higher PHP version for newer framework releases.
Installation
Laravel auto-discovery registers the service provider. Publish the config only when you need to override defaults:
Tables
Example for a translated Country model:
If your default language lives on the main model table, add the translated column there and enable native fallback on the model:
Then set:
Models
By convention, Country uses CountryTranslation. Override it when needed:
Usage
Configuration
Important defaults:
With database mode enabled, the middleware resolves app()->getLocale() through your language model and stores the matching id on the request.
With database mode disabled, configure languages directly:
Middleware
The middleware is no longer pushed globally by default in 2.x.
Register it where translated route content needs automatic language id resolution:
If you really want the old global behavior:
Polymorphic Translations
Implement PolyTrans and set the morph name:
Testing
All versions of laravel-translatable-db with dependencies
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0