Download the PHP package levgenij/filament-translatable without Composer
On this page you can find all versions of the php package levgenij/filament-translatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download levgenij/filament-translatable
More information about levgenij/filament-translatable
Files in levgenij/filament-translatable
Package filament-translatable
Short Description Automatic translation support for Filament Resources based on levgenij/laravel-translatable
License MIT
Homepage https://github.com/levgenij/filament-translatable
Informations about the package filament-translatable
Filament Translatable
Seamless multilingual support for Filament Resources with automatic translatable field generation based on levgenij/laravel-translatable.
📦 Version Compatibility
Please install the version that matches your Filament version:
| Filament Version | Package Version | Branch | Installation |
|---|---|---|---|
| Filament v5.x | ^2.0 |
main |
composer require levgenij/filament-translatable:^2.0 |
| Filament v3/v4 | ^1.0 |
v1 |
composer require levgenij/filament-translatable:^1.0 |
Note: This documentation is for Filament v5. If you are using Filament v3 or v4, please switch to the v1 documentation.
Features
- Zero Configuration - Translatable fields are detected automatically from the model
- Language Tabs - Fields are grouped into tabs for each locale
- Locale Badges - Visual indicators next to field labels:
Title [EN] - Clean Form Schema - No wrappers or special syntax needed
- Single Locale Mode - No tabs or badges when only one locale is configured
- Filament 5 - Built for Filament 5 (Schema API)
Requirements
- PHP 8.2+
- Laravel 11+
- Filament 5.0+
- levgenij/laravel-translatable 3.0+
Installation
Install the package via Composer:
The package will auto-register its service provider.
Publish Configuration (Optional)
Quick Start
1. Configure Your Model
Your model must use the Translatable trait from levgenij/laravel-translatable:
2. Add Trait to Resource
3. Add Trait to Create/Edit Pages
CreateRecord:
EditRecord:
That's it! Your form will now automatically display translatable fields in language tabs.
Configuration
Locales
By default, the package reads locales from config/translatable.php (the parent package). You can override this in config/filament-translatable.php:
Badge Style
Customize the locale badge appearance:
How It Works
Architecture
Data Flow
-
Resource - The
TranslatableResourcetrait provides thegetTranslatableAttributes()method that reads the model's$translatableproperty. -
Page - The
HasTranslatableFieldstrait intercepts theform()method and transforms the schema:- Finds fields that exist in
$model->translatable - Groups them into language tabs (when multiple locales)
- Adds locale badges to labels
- Non-translatable fields remain unchanged
- Finds fields that exist in
- Saving - The trait automatically:
- Extracts translation data from the form
- Saves them via
$model->saveTranslation($locale, $data)
Form Data Structure
Data in the form is stored in this structure:
UI Behavior
Multiple Languages
When multiple languages are configured, translatable fields are grouped into tabs:
Single Language
When only one language is configured:
- Tabs are not shown
- Badges are not shown
- Fields are displayed normally
Advanced Usage
Overriding mutateFormDataBeforeFill
If you need additional logic when filling the form:
Overriding mutateFormDataBeforeCreate/Save
Custom Validation
Validation works as expected. Use the translations.{locale}.{field} path for custom rules:
Database Structure
The package works with levgenij/laravel-translatable which uses separate translation tables:
Troubleshooting
Fields are not transformed
Make sure that:
- Resource has
use TranslatableResource; - Page has
use HasTranslatableFields; - Model has
$translatableproperty with correct fields - Model uses
use Levgenij\LaravelTranslatable\Translatable
Translations are not saved
Make sure that:
- Table
{table}_translationsexists - Fields are in model's
$fillable - Fields are in model's
$translatable
Error "Call to undefined method saveTranslation"
Model does not use the Levgenij\LaravelTranslatable\Translatable trait.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Levgenij
- All Contributors
License
The MIT License (MIT). Please see License File for more information.