PHP code example of asignua / filament-translatable-fields
1. Go to this page and download the library: Download asignua/filament-translatable-fields library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asignua / filament-translatable-fields example snippets
use Spatie\Translatable\HasTranslations;
class Post extends Model
{
use HasTranslations;
public array $translatable = ['title', 'body'];
}
use Asignua\FilamentTranslatableFields\Forms\Translatable;
use Asignua\FilamentTranslatableFields\Forms\TranslatableTabs;
// A factory: you build the input for each language.
TranslatableTabs::make('title', fn (string $locale) => TextInput::make('title')->maxLength(255))
->
// config/filament-translatable-fields.php
'locales' => null, // null → your app's translatable.locales, if defined → [app.locale, app.fallback_locale]
'default_locale' => null, // null → app.locale (or the first language)
'labels' => [], // ['uk' => 'Українська']; default: the language's own name (intl) or the code
'marker' => '[:locale] ', // '' disables the marker
'empty_badges' => false, // opt-in: the inputs become live(onBlur: true) to keep the badge current
TranslatableFields::locales(['uk', 'en', 'pl']); // or a closure
TranslatableFields::defaultLocale('uk');
TranslatableFields::labels(['pl' => 'Polski']);