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