Download the PHP package asignua/filament-translatable-fields without Composer

On this page you can find all versions of the php package asignua/filament-translatable-fields. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-translatable-fields

Filament Translatable Fields

Stand With Ukraine Latest Version on Packagist Tests Total Downloads License Plumb score

Filament Translatable Fields

Per-field language tabs for spatie/laravel-translatable in Filament 5. Every language is a real input in the form state at the same time, so translations survive a Repeater, a Builder, a ->relationship() repeater and a settings page.

Filament's official translatable plugin was discontinued after v3, and the replacements switch ONE global locale for the whole form. That is exactly what breaks nested fields: the order and the data of a repeater are lost after the editor switches language (filamentphp/filament#8328, plus dozens of help threads and ideas about repeaters, builders, relationships and settings pages). Here there is no global locale: each translatable field carries its own tabs and its own title.uk / title.en state.

Screenshots

Language tabs on a field, with copy from the default language

A Repeater with translatable fields and

Requirements

Installation

There is no panel plugin to register and no asset to publish: the package is plain Filament components. Optionally publish the config:

Your model uses spatie as usual:

Usage

The factory component keeps the attribute name (title); the plugin binds it to title.{locale}. Inside the tabs:

Method Effect
requiredDefault() the default language must be filled (the field's first language when its locales() leave the global default out)
requiredIn(['uk', 'en']) those languages must be filled
requiredAll() every language of the field (its own locales()) must be filled
requiredAny() at least one language; the error shows on the default language (with one language: plain required())
locales(['uk', 'en']) this field only offers these languages
copyFromDefault(false) hide the "Copy from Українська" hint action (it asks before overwriting a filled language; with the default one empty it shows a "nothing to copy" notification instead)
emptyBadges() opt in to an "empty" badge on tabs of unfilled languages (off by default)

A tab whose input (or anything inside it, e.g. a repeater in a language tab) has a validation error gets a red ! badge. Error messages name the language (Title (English)).

Repeaters, builders, relationships, settings pages

Nothing special — put the component where the field goes:

On a page without a model (settings in a table, a cache, a config file) the state is simply an array: ->fill(['site_name' => ['uk' => '…', 'en' => '…']]) and $this->form->getState() returns the same shape.

How it decides where the value comes from: whatever was passed to fill() wins. EditRecord and a ->relationship() repeater fill the form from attributesToArray(), which already holds the whole map, so a change made in mutateFormDataBeforeFill() stays. Only when {field} did not arrive as an array — or when the form is filled with no data at all (a record Action's default mount, a custom page with ->record($record) and fill()) — are the languages read from $record->getTranslation($field, $locale, false), and only when the field sits directly in the schema that was given that record. The record is read before the language inputs hydrate, so their own afterStateHydrated() hooks receive the record's value. A JSON repeater/builder item, or a group with its own statePath(), is never read from the record — so an item field called title is never overwritten by the record's own title.

Saving

Filament's default save already works with spatie: $model->fill(['title' => ['uk' => 'a', 'en' => 'b']]) calls setTranslations(), and a cleared language ('en' => null) is cleared. You do not need anything else for a normal model. The optional page trait is a helper for the rest:

For the same normalisation outside a page: TranslatableFields::normalize($data, ['title', 'body']).

Tables and infolists

The value of the current language; if it is empty, the default language, then any filled one, prefixed with a marker ([en] Hello) so an editor can tell a borrowed text from a translated one. Nothing is written back. Use them in the admin only — [en] in a public <title> is an SEO bug. searchAcrossLocales() searches title->uk, title->en, … case-insensitively — ilike on PostgreSQL, lower(…) like lower(?) on MySQL/MariaDB, plain like on SQLite (ASCII letters only); team.name searches through whereHas('team'). sortableByLocale() sorts by the shown text — the current language, then the default, then the rest — and works on the table's own attributes only (it throws for team.name). A cleared language (stored by spatie as JSON null) neither matches a search nor sorts as the text null: on MySQL/MariaDB it is mapped to SQL NULL and falls through to the next language.

Configuration

In code (for example AppServiceProvider::boot()), which wins over the config:

Gotchas

Translations

The interface ships in English, Ukrainian, German, Spanish, French, Italian, Dutch, Polish, Brazilian Portuguese and Turkish under the filament-translatable-fields::translatable-fields namespace; a test keeps every language in step.

AI agents

The package ships Laravel Boost guidelines (resources/boost/guidelines/core.blade.php).

Testing

The suite runs on Orchestra Testbench with a workbench/ resource (a model with translatable columns, a JSON Repeater, a Builder, a relationship Repeater) and a Livewire settings page.

Changelog

See CHANGELOG.md.

License

The MIT License (MIT). See LICENSE.md.


All versions of filament-translatable-fields with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
filament/filament Version ^5.0
illuminate/contracts Version ^12.0|^13.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-translatable Version ^6.11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package asignua/filament-translatable-fields contains the following files

Loading the files please wait ...