This package enables you to implement the following:
This package depends on spatie/laravel-translatable, Please check it first to set up your translation logic in your project.
You can install the package via composer:
composer require 34ml/filament-translatable-field
You can publish the config file with:
php artisan vendor:publish --tag="filament-translatable-field-config"
This is the content of the published config file where fields are created for each language listed here
return [ 'locales' => [ 'en' => 'English', 'ar' => 'Arabic', ], 'select_translation_field_name' => 'select_language',];
..._34ML\FilamentTranslatableField::make( 'your_translatable_field_name', \Filament\Forms\Components\TextInput::class, // The field type class)
..._34ML\FilamentTranslatableField::make( 'your_translatable_field_name', \Filament\Forms\Components\TextInput::class, // The field type class 'your_field_displayed_name', // Optional)
..._34ML\FilamentTranslatableField::make( 'your_translatable_field_name', \Filament\Forms\Components\TextInput::class, // The field type class // add your filament field functions as a callback, you can add it as one function callbacks: function (){ $this->required(); $this->numeric(); return $this; // You have to return the field or the callbacks won't work })
If you want to add a language selector that shows only the selected language's fields instead of showing all fields you can simply add this field in your resource, view, create,or edit pages inside the form function
use _34ML\FilamentTranslatableField\Forms\Components\LanguageSelector;Â return $form ->schema([ LanguageSelector::make(), ]);
you need to add this code to your relationship manager
public static function getRecordTitle(?Model $record): ?string{ return $record->getTranslation('your_title_column', config('filament-translatable-field.locales')[0]);}
The MIT License (MIT). Please see License File for more information.
34ML (https://34ml.com) a software company based in Egypt, We connect businesses and users through innovative mobile apps, built with user experience, performance, and security in mind. Our expertise in AI, machine learning, VR, and AR allows us to create truly transformative experiences.