variety of premium plugins

Learn More

translatable-pro

Translatable Pro is a premium package, get your license here

Translatable Pro support auto configuration for your table and resources, it will set them searchable and sortable without having to change anything in your code.

if you want to disable this and have more control, you can set the config option auto_phraseable to false

1'auto_phraseable' => false,

Usage With Factories

to add translation in the database factories simply add the array for your attribute:

1public function definition(): array
2{
3 return [
4 'title' => [
5 'ar' => fake()->name(),
6 'en' => fake()->name(),
7 ],
8 // ....
9 ];
10}

Resource

remember to lazy load your phrases by overriding the query:

note that is your config auto_phraseable is true, this will be handel dynamically

1->modifyQueryUsing(fn (Builder $query) => $query->with(['phrases','cat.phrases']))

Tables

Searchable

to make a column searchable, you should call the macro phraseSearchable:

note that is your config auto_phraseable is true, this will be handel dynamically

1TextColumn::make('title')->phraseSearchable(),

Sortable

to all ow sorting on the text column call the macro phraseSortable

note that is your config auto_phraseable is true, this will be handel dynamically

1TextColumn::make('title')->phraseSortable(),

and for convenient you can use phraseable, that allow Searchable and Sortable on the text column

note that is your config auto_phraseable is true, this will be handel dynamically

1TextColumn::make('title')->phraseable(),

to disable searchable use:

1->seachable(false)

to disable sortable use:

1->sortable(false)

Relation in column

you can call the phrases as you normally do with filament for relations:

1TextColumn::make('category.name'),

Filters

to enable translatable label in filters, set the getOptionLabelFromRecordUsing

1SelectFilter::make('category_id')
2 ->getOptionLabelFromRecordUsing(fn (Category $record) => $record->name ?? '-')
3 ->label('Category')
4 ->relationship('category', 'id'),

Forms

Form Component

you can use the translatable component

1MultiLang::make('title'),

Live Updates

in some cases you may need to access the state, for example to generate the slug, here is how you can do it:

1->afterStateUpdated(function (Get $get, Set $set, $state) {
2 $set('slug', Str::slug($get('title.en')));
3 // or to use the current active language:
4 $set('slug', Str::slug($get('title.'.app()->getLocale())));
5})

Select with relations and searchable:

to make the select searchable in the relation with phrases:

1Select::make('cat_id')
2 ->relationship('cat', 'name')
3 ->phrasesSearchable(),

Custom Schema

By default the component will render a text input, but you can pass any filament component:

1MultiLang::make('desc')
2 ->setTabSchema(
3 TiptapEditor::make('desc'),
4 ),

Component options

Todo