承接 alareqi/filament-translatable-fields 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alareqi/filament-translatable-fields

最新稳定版本:v2.0.7

Composer 安装命令:

composer require alareqi/filament-translatable-fields

包简介

This package adds a way to interact with alareqi/translatable-fields in Filament.

README 文档

README

Latest Version on Packagist Total Downloads

This package adds a way to make all filament fields translatable. It uses the spatie/laravel-translatable package in the background.

Compatible with Laravel 10, 11, and 12.

Installation

You can install the package via composer:

composer require alareqi/filament-translatable-fields

Add the plugin to your desired Filament panel:

use Alareqi\FilamentTranslatableFields\FilamentTranslatableFieldsPlugin;

class FilamentPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugins([
                FilamentTranslatableFieldsPlugin::make(),
            ]);
    }
}

You can specify the supported locales:

use Alareqi\FilamentTranslatableFields\FilamentTranslatableFieldsPlugin;

class FilamentPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugins([
                FilamentTranslatableFieldsPlugin::make()
                    ->supportedLocales([
                        'en' => 'English',
                        'ar' => 'العربية',
                    ]),
            ]);
    }
}

By default, the package will use the app.locale if you don't specify the locales.

Usage

You can simply add ->translatable() to any field to make it translatable.

use Filament\Forms\Components\TextInput;

TextInput::make('name')
    ->label('Name')
    ->translatable(),

Overwrite locales

If you want to overwrite the locales on a specific field you can set the locales through the second parameter of the ->translatable() function.

use Filament\Forms\Components\TextInput;

TextInput::make('name')
    ->label('Name')
    ->translatable(true, ['en' => 'English', 'ar' => 'العربية', 'fr' => 'French']),

Good to know

This package will substitute the original field with a Filament\Forms\Components\Tabs component. This component will render the original field for each locale.

All chained methods you add before calling ->translatable() will be applied to the original field. All chained methods you add after calling ->translatable() will be applied to the Filament\Forms\Components\Tabs component.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 69
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-26