Download the PHP package ezappslab/filament-translatable without Composer
On this page you can find all versions of the php package ezappslab/filament-translatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ezappslab/filament-translatable
More information about ezappslab/filament-translatable
Files in ezappslab/filament-translatable
Package filament-translatable
Short Description Filament Translatable adds locale-aware resource pages to FilamentPHP panels using Spatie Laravel Translatable
License MIT
Informations about the package filament-translatable
Filament Translatable
Filament Translatable adds locale-aware resource pages for Filament panels that use spatie/laravel-translatable.
The package provides:
- A Filament panel plugin for configuring available locales.
- Page concerns for create, edit, list, and view resource pages.
- A locale selector header action.
- A content driver that reads, writes, displays, and searches the active locale of Spatie translatable attributes.
Requirements
- PHP 8.2 or higher
- Filament 5
spatie/laravel-translatable6.11.4 or higher
Installation
Install the package with Composer:
Run the install command:
The installer can publish the configuration file and register the package service provider in your application.
Configuration
Configure the locales that should be available in your Filament panel:
You can also configure locales directly when registering the plugin on a panel:
Preparing Models
Use Spatie's HasTranslations trait on any model that has translated attributes.
The translated columns should be JSON-compatible columns in your database.
Example migration columns:
Using Translatable Resource Pages
Add the matching concern to each Filament resource page and add the locale selector to the page header actions.
List Page
Create Page
Edit Page
View Page
Resource Example
Once the page concerns are installed, build your resource form and table normally. The package resolves translatable fields through the currently selected locale.
When a user selects Bulgarian, name and description are read from and written to
the bg translation values. Non-translatable attributes, such as is_active, are
handled as normal model attributes.
Relationship Fields
Translatable fields inside Filament relationship sections are also supported. Mark the related model attributes as translatable and use the same page concerns on the parent resource pages.
In this example, profile.headline and profile.biography can be translated per
locale when the Profile model uses Spatie's HasTranslations trait.
Relation Managers
Use HasTranslatableRelationManager on Filament relation managers that manage
models with Spatie translatable attributes. Add SelectLocaleAction to the table
header actions so users can switch the active locale.
The relation manager uses its own active locale session key, scoped by panel, page, and relation manager class.
Scripts
composer lint: Run Pint and PHPStan.composer test: Run Pest tests.composer build: Build workbench assets.composer serve: Serve the workbench application.
Documentation
For more detailed information about the included tools, see docs/tooling.md.
All versions of filament-translatable with dependencies
spatie/laravel-package-tools Version ^1.93
filament/filament Version ^5.0
spatie/laravel-translatable Version ^6.11.4