PHP code example of jegex / filament-translatable

1. Go to this page and download the library: Download jegex/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/ */

    

jegex / filament-translatable example snippets


use Jegex\FilamentTranslatable\Enums\TranslationMode;

FilamentTranslatablePlugin::make()
    ->translationMode(TranslationMode::Astrotomic)

use Jegex\FilamentTranslatable\FilamentTranslatablePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(FilamentTranslatablePlugin::make());
}

FilamentTranslatablePlugin::make()
    ->locales(['en', 'id', 'fr', 'de']),

FilamentTranslatablePlugin::make()
    ->locales([
        'en' => __('('English'),
        'id' => __('Indonesian'),
        'fr' => __('French'),
    ])

FilamentTranslatablePlugin::make()
    ->locales(fn () => Language::pluck('code', 'name'))

FilamentTranslatablePlugin::make()
    ->defaultLocale('en'),

FilamentTranslatablePlugin::make()
    ->displayFlagsInLocaleLabels(true)

FilamentTranslatablePlugin::make()
    ->flagWidth('24px')

use Jegex\FilamentTranslatable\Forms\Component\Translations;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;

Translations::make('translations')
    ->schema([
        TextInput::make('title'),
        Textarea::make('content'),
    ])

use Jegex\FilamentTranslatable\Forms\Component\Translations;

Translations::make('translations')
    ->vertical()
    ->schema([
        TextInput::make('title'),
        Textarea::make('content'),
    ])

Translations::make('translations')
    ->scrollable()
    ->locales(['en', 'id', 'fr', 'de', 'es', 'it', 'pt', 'ru', 'zh', 'ja', 'ko', 'ar'])
    ->schema([...])

use Jegex\FilamentTranslatable\Forms\Component\Translations;

Translations::make('translations')
    ->schema([
        TextInput::make('title'),
    ])

use Jegex\FilamentTranslatable\Forms\Component\Translations;

Translations::make('translations')
    ->displayFlagsInLocaleLabels(true)
    ->flagWidth('24px')
    ->schema([...])

use Jegex\FilamentTranslatable\Enums\TranslationMode;
use Jegex\FilamentTranslatable\Forms\Component\Translations;

Translations::make('translations')
    ->translationMode(TranslationMode::Astrotomic)
    ->schema([
        TextInput::make('name'),
    ])

use Jegex\FilamentTranslatable\Forms\Component\Translations;

Translations::make()
    ->displayNamesInLocaleLabels(false)
    ->displayFlagsInLocaleLabels(true)
    ->flagWidth('32px')

use Jegex\FilamentTranslatable\FilamentTranslatablePlugin;
use Jegex\FilamentTranslatable\Forms\Component\Translations;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\RichEditor;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            FilamentTranslatablePlugin::make()
                ->locales(['en', 'id', 'fr', 'de'])
                ->defaultLocale('en')
                ->displayFlagsInLocaleLabels(true)
                ->displayNamesInLocaleLabels(true)
                ->flagWidth('24px')
        );
}

public static function form(Form $form): Form
{
    return $form->schema([
        TextInput::make('slug'),
        
        Translations::make('translations')
            ->vertical()
            ->displayFlagsInLocaleLabels()
            ->schema([
                TextInput::make('title'),
                RichEditor::make('content'),
            ])
            ->columns(1),
    ]);
}
bash
php artisan filament:assets