jegex/filament-translatable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jegex/filament-translatable

Composer 安装命令:

composer require jegex/filament-translatable

包简介

Translation component for Filament PHP.

README 文档

README

FILAMENT 4.x FILAMENT 5.x Packagist GitHub Tests Action Status Downloads

Filament Translatable is a flexible package that provides a complete solution for managing multilingual content in Filament admin panels. It uses a tabbed interface with Repeater component, allowing you to easily create translatable form fields with an intuitive UI.

Key Features

  • Tab-Based UI with Repeater — extends Filament Repeater, leveraging all Repeater features
  • Locale Tabs with Flags — horizontal or vertical tabs with 200+ built-in SVG flags
  • Clone Locale — duplicate translations between locales
  • Multiple Translation Backends — supports both spatie/laravel-translatable and astrotomic/laravel-translatable
  • Flexible Locale Configuration — define locales globally or per-component
  • Vertical & Horizontal Tabs — choose your preferred layout
  • Scrollable Tabs — for managing many languages

Installation

You can install the package via composer:

composer require jegex/filament-translatable

Publish the assets:

php artisan filament:assets

Configuration

With spatie/laravel-translatable

The Spatie package is the default translation backend. Follow the instructions in the Spatie documentation to properly configure your models.

With astrotomic/laravel-translatable

The Astrotomic package is an alternative translation backend.

Follow the Astrotomic documentation to configure your models.

When using the Astrotomic package, configure the plugin to use Astrotomic mode:

use Jegex\FilamentTranslatable\Enums\TranslationMode;

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

Setup

use Jegex\FilamentTranslatable\FilamentTranslatablePlugin;

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

Setting translatable locales

To set up the locales that can be used to translate content, pass an array of locales to the locales() plugin method:

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

You can set locale labels using key => value array:

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

Also, you can pass a Closure:

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

Setting default locale

You can set the default locale using the defaultLocale() method:

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

Enable or disable flags in locale labels

You can enable or disable flags in locale labels (disabled by default):

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

Setting flag width

You can set the flag width using:

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

Usage

Basic Usage

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'),
    ])

Vertical Tabs

You can display translations as vertical tabs:

use Jegex\FilamentTranslatable\Forms\Component\Translations;

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

Scrollable Tabs

Enable horizontal scroll for tabs when you have many languages:

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

Clone Locale

The package includes a built-in clone locale feature that allows you to duplicate translations from one locale to another:

use Jegex\FilamentTranslatable\Forms\Component\Translations;

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

Display Flags

Enable flags in locale labels:

use Jegex\FilamentTranslatable\Forms\Component\Translations;

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

Using with Astrotomic Mode

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

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

Overriding Plugin Settings per Component

You can override the global plugin settings directly on individual components:

use Jegex\FilamentTranslatable\Forms\Component\Translations;

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

Full Example

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),
    ]);
}

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

jegex/filament-translatable 适用场景与选型建议

jegex/filament-translatable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「filament」 「filament-plugin」 「filamentphp」 「filament-translatable」 「jegex」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jegex/filament-translatable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jegex/filament-translatable 我们能提供哪些服务?
定制开发 / 二次开发

基于 jegex/filament-translatable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-09