PHP code example of webard / filament-translatable
1. Go to this page and download the library: Download webard/filament-translatable 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/ */
webard / filament-translatable example snippets
use Filament\Forms\Components\TextInput;
TextInput::make('name')
->translatable()
use Happenv\FilamentTranslatable\FilamentTranslatablePlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(FilamentTranslatablePlugin::make());
}
use Happenv\FilamentTranslatable\Enums\TranslationMode;
FilamentTranslatablePlugin::make()
->translationMode(TranslationMode::Astrotomic)
use Filament\Forms\Components\Field;
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make()
->schema([
// Fields
])
->fieldTranslatableLabel(fn (Field $field, string $locale) => __($field->getName(), locale: $locale))
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->schema([
// Fields
])
->prefixLocaleLabel()
->suffixLocaleLabel()
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->formatLocaleLabelUsing(fn (string $locale, string $label) => "[{$label}]");
use Filament\Forms\Components\Field;
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
// ...
->prefixLocaleLabel(function(Field $field) {
// Must return a boolean value
return $field->getName() == 'title';
})
->suffixLocaleLabel(function(Field $field) {
// Must return a boolean value
return $field->getName() == 'title';
})
use Filament\Actions\Action;
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->actions([
Action::make('fillDumpTitle')
])
use Filament\Actions\Action;
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->actions([
Action::make('fillDumpTitle')
->action(function (array $arguments) {
$locale = $arguments['locale'];
// ...
})
])
use Filament\Forms\Components\TextInput;
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make()
->schema(fn (string $locale) => [TextInput::make('title')->
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make()
->contained(false)
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make()
->vertical()
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make()
->displayNamesInLocaleLabels(false)
->displayFlagsInLocaleLabels(true)
->flagWidth('48px')
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->schema([
Forms\Components\TextInput::make('title'),
Forms\Components\TextInput::make('description'),
])
->exclude(['description'])
use Happenv\FilamentTranslatable\Forms\Component\Translations;
Translations::make('translations')
->schema([
Forms\Components\TextInput::make('title'),
Forms\Components\TextInput::make('description'),
])
->