{"id":37265201,"url":"https://github.com/fnx-software/filament-astrotomic","last_synced_at":"2026-01-26T09:03:08.976Z","repository":{"id":317152465,"uuid":"1066178373","full_name":"fnx-software/filament-astrotomic","owner":"fnx-software","description":"Manage multilingual content in Filament v4+ with astrotomic/laravel-translatable, supercharged with a reactive Locale Switcher, sortable/searchable Columns, and a translatable Select component.","archived":false,"fork":false,"pushed_at":"2026-01-15T08:51:16.000Z","size":439,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-16T01:42:23.022Z","etag":null,"topics":["astrotomic","filament","filament-plugin","filament4","filamentphp","laravel","laravel-translatable","localization","multilingual","translations"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnx-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-29T06:14:23.000Z","updated_at":"2026-01-15T08:51:20.000Z","dependencies_parsed_at":"2025-09-29T08:24:47.160Z","dependency_job_id":"e7f8bc39-0b52-4101-ab1a-160ccce324fa","html_url":"https://github.com/fnx-software/filament-astrotomic","commit_stats":null,"previous_names":["fnx-software/filament-astrotomic"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/fnx-software/filament-astrotomic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnx-software%2Ffilament-astrotomic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnx-software%2Ffilament-astrotomic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnx-software%2Ffilament-astrotomic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnx-software%2Ffilament-astrotomic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnx-software","download_url":"https://codeload.github.com/fnx-software/filament-astrotomic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnx-software%2Ffilament-astrotomic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28771522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T08:38:24.014Z","status":"ssl_error","status_checked_at":"2026-01-26T08:38:22.080Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astrotomic","filament","filament-plugin","filament4","filamentphp","laravel","laravel-translatable","localization","multilingual","translations"],"created_at":"2026-01-16T00:06:01.033Z","updated_at":"2026-01-26T09:03:08.970Z","avatar_url":"https://github.com/fnx-software.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Filament Astrotomic Translations\n\n[![Total Downloads](https://img.shields.io/packagist/dt/fnx-software/filament-astrotomic)](https://packagist.org/packages/fnx-software/filament-astrotomic)\n\nThis package is an extension for **Filament v4+** and [laravel-translatable](https://docs.astrotomic.info/laravel-translatable) to easily manage multilingual content in your admin panel.\n\nThis is an enhanced fork of [doriiaan/filament-astrotomic](https://github.com/Doriiaan/filament-astrotomic) and the original [cactus-galaxy/filament-astrotomic](https://github.com/CactusGalaxy/FilamentAstrotomic), updated for Filament 4 and introducing powerful new features like a reactive `LocaleSwitcher` and dedicated components for displaying translated content.\n\n\u003cimg width=\"3072\" height=\"892\" alt=\"CleanShot 2025-09-29 at 12 02 44@2x\" src=\"https://github.com/user-attachments/assets/a2ef2b14-db7b-4d99-8fc9-dd30ed81a4a7\" /\u003e\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require fnx-software/filament-astrotomic\n```\n\nPublish the configuration for `astrotomic/laravel-translatable`:\n\n```bash\nphp artisan vendor:publish --tag=\"translatable\"\n```\n\nConfigure the locales your app should use in `config/translatable.php`:\n\n```php\n// config/translatable.php\n'locales' =\u003e [\n    'en',\n    'es',\n    'fr',\n],\n```\n\n## Setup\n\n### Adding the Plugin to a Panel\n\nRegister the plugin in your Panel Provider:\n\n```php\n// app/Providers/Filament/AdminPanelProvider.php\nuse Fnxsoftware\\FilamentAstrotomic\\FilamentAstrotomicPlugin;\nuse Filament\\Panel;\n\npublic function panel(Panel $panel): Panel\n{\n    return $panel\n        // ...\n        -\u003eplugins([\n            FilamentAstrotomicPlugin::make(),\n        ]);\n}\n```\n\n### Customizing the Main Locale (Optional)\n\nBy default, the main locale is taken from your `config/translatable.php` file. You can override this dynamically when registering the plugin.\n\n**Set a static main locale:**\n```php\nFilamentAstrotomicPlugin::make()\n    -\u003emainLocale('ar')\n```\n\n**Set a dynamic main locale (e.g., from database settings):**\n```php\nuse App\\Models\\Setting;\n\nFilamentAstrotomicPlugin::make()\n    -\u003emainLocale(fn () =\u003e Setting::where('key', 'default_locale')-\u003efirst()?-\u003evalue ?? 'en')\n```\n### Customizing the Available Locales (Optional)\n\nBy default, the available locales are loaded from your `config/translatable.php` file.\n\nYou can override the locale list when registering the plugin, which is useful when your locales are stored in the database (e.g., per-tenant settings).\n\n**Set a static locales list:**\n```php\nFilamentAstrotomicPlugin::make()\n    -\u003elocales(['ar', 'en', 'fr'])\n```\n\n## Basic Usage\n\n### 1. Preparing Your Model\n\nMake your Eloquent model translatable as described in the [laravel-translatable documentation](https://docs.astrotomic.info/laravel-translatable/installation#models).\n\n```php\n// app/Models/Post.php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Astrotomic\\Translatable\\Contracts\\Translatable as TranslatableContract;\nuse Astrotomic\\Translatable\\Translatable;\n\nclass Post extends Model implements TranslatableContract\n{\n    use Translatable;\n\n    public array $translatedAttributes = ['title', 'content'];\n    protected $fillable = ['author_id'];\n}\n```\n\n### 2. Preparing Your Resource\n\nApply the `ResourceTranslatable` trait to your Filament resource class:\n\n```php\n// app/Filament/Resources/PostResource.php\nuse Fnxsoftware\\FilamentAstrotomic\\Resources\\Concerns\\ResourceTranslatable;\nuse Filament\\Resources\\Resource;\n\nclass PostResource extends Resource\n{\n    use ResourceTranslatable;\n\n    // ...\n}\n```\n\n### 3. Making Resource Pages Translatable\n\nYou must also apply the corresponding translatable trait to each of your resource's pages.\n\n**List Page:**\n```php\n// app/Filament/Resources/PostResource/Pages/ListPosts.php\nuse Fnxsoftware\\FilamentAstrotomic\\Resources\\Pages\\ListTranslatable;\nuse Filament\\Resources\\Pages\\ListRecords;\n\nclass ListPosts extends ListRecords\n{\n    use ListTranslatable;\n    // ...\n}\n```\n\n**Create Page:**\n```php\n// app/Filament/Resources/PostResource/Pages/CreatePost.php\nuse Fnxsoftware\\FilamentAstrotomic\\Resources\\Pages\\CreateTranslatable;\nuse Filament\\Resources\\Pages\\CreateRecord;\n\nclass CreatePost extends CreateRecord\n{\n    use CreateTranslatable;\n    // ...\n}\n```\n\n**Edit Page:**\n```php\n// app/Filament/Resources/PostResource/Pages/EditPost.php\nuse Fnxsoftware\\FilamentAstrotomic\\Resources\\Pages\\EditTranslatable;\nuse Filament\\Resources\\Pages\\EditRecord;\n\nclass EditPost extends EditRecord\n{\n    use EditTranslatable;\n    // ...\n}\n```\n\n**View Page:**\n```php\n// app/Filament/Resources/PostResource/Pages/ViewPost.php\nuse Fnxsoftware\\FilamentAstrotomic\\Resources\\Pages\\ViewTranslatable;\nuse Filament\\Resources\\Pages\\ViewRecord;\n\nclass ViewPost extends ViewRecord\n{\n    use ViewTranslatable;\n    // ...\n}\n```\n\n## Form Components\n\n### `TranslatableTabs` for Localized Fields\n\nTo manage translations for your model's attributes, use the `TranslatableTabs` component. It automatically creates a tab for each locale.\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Schemas\\Components\\TranslatableTabs;\nuse Fnxsoftware\\FilamentAstrotomic\\TranslatableTab;\nuse Filament\\Forms\\Components\\TextInput;\nuse Filament\\Forms\\Components\\RichEditor;\nuse Filament\\Forms\\Form;\n\npublic static function form(Form $form): Form\n{\n    return $form-\u003eschema([\n        TranslatableTabs::make()\n            -\u003elocaleTabSchema(fn (TranslatableTab $tab) =\u003e [\n                TextInput::make($tab-\u003emakeName('title'))\n                    -\u003erequired($tab-\u003eisMainLocale()), // Required only for the main language\n\n                RichEditor::make($tab-\u003emakeName('content')),\n            ])\n    ]);\n}\n```\n\u003cimg width=\"3072\" height=\"892\" alt=\"CleanShot 2025-09-29 at 12 03 33@2x\" src=\"https://github.com/user-attachments/assets/15c1f035-4997-476f-b249-16da8c007e48\" /\u003e\n\n#### Customizing Field Labels\n\nTo make it clearer which language a field belongs to, you can use the `makePrefixLabel()` and `makeSuffixLabel()` methods on the `TranslatableTab` object to automatically add the locale name to your field labels.\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Schemas\\Components\\TranslatableTabs;\nuse Fnxsoftware\\FilamentAstrotomic\\TranslatableTab;\nuse Filament\\Forms\\Components\\TextInput;\nuse Filament\\Forms\\Components\\Textarea;\n\nTranslatableTabs::make()\n    -\u003elocaleTabSchema(fn (TranslatableTab $tab) =\u003e [\n        TextInput::make($tab-\u003emakeName('title'))\n            // Renders label as \"Title (English)\"\n            -\u003elabel($tab-\u003emakePrefixLabel('Title')),\n\n        Textarea::make($tab-\u003emakeName('description'))\n            // Renders label as \"(English) Description\"\n            -\u003elabel($tab-\u003emakeSuffixLabel('Description')),\n    ])\n```\n#### Custom Locales Per `TranslatableTabs` Instance\n\nBy default, `TranslatableTabs` will use the locales configured for the plugin (or the `translatable.locales` config).\n\nIf you need to override the locales for a specific form (or even for a single set of fields), you may pass a custom list directly to the component:\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Schemas\\Components\\TranslatableTabs;\nuse Fnxsoftware\\FilamentAstrotomic\\TranslatableTab;\nuse Filament\\Forms\\Components\\TextInput;\n\nTranslatableTabs::make()\n    -\u003ecustomLocales(['ar', 'en', 'fr', 'pt'])\n    -\u003elocaleTabSchema(fn (TranslatableTab $tab) =\u003e [\n        TextInput::make($tab-\u003emakeName('label'))\n            -\u003erequired($tab-\u003eisMainLocale()),\n    ])\n```\n\n### `TranslatableSelect` for Relationships\n\nThe standard `Select::relationship()` component does not work with `astrotomic/laravel-translatable`. This package provides a `TranslatableSelect` component to correctly load, search, and display options from a translatable `BelongsTo` relationship.\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Forms\\Components\\TranslatableSelect;\nuse Filament\\Forms\\Form;\n\npublic static function form(Form $form): Form\n{\n    return $form-\u003eschema([\n        // ... other fields\n        TranslatableSelect::make('country_id')\n            -\u003etranslatableRelationship('country', 'name')\n            -\u003esearchable()\n            -\u003epreload()\n            -\u003elabel('Country')\n            -\u003erequired(),\n    ]);\n}\n```\nThis will correctly display the country names in the current locale, and the search functionality will also work on the translated names.\n\n\n## Displaying Translated Content Reactively\n\nThis package provides a seamless way to view translated content on your List and View pages using a `LocaleSwitcher` action that works with dedicated table columns and infolist entries.\n\n### 1. Add the `LocaleSwitcher` Action\n\nAdd the `LocaleSwitcher` to the header actions of your List and View pages.\n\n```php\n// In your List page (e.g., ListPosts.php)\nuse Fnxsoftware\\FilamentAstrotomic\\Actions\\LocaleSwitcher;\nuse Filament\\Actions\\CreateAction;\n\nprotected function getHeaderActions(): array\n{\n    return [\n        CreateAction::make(),\n        LocaleSwitcher::make(), // Add this\n    ];\n}\n```\n\u003cimg width=\"3072\" height=\"898\" alt=\"CleanShot 2025-09-29 at 12 04 48@2x\" src=\"https://github.com/user-attachments/assets/a59f0fa7-4709-483e-bda6-3e3a9604ad0b\" /\u003e\n\n\n### 2. Use `TranslatableColumn` in Tables\n\nThe `TranslatableColumn` automatically displays the translation for the selected locale and provides out-of-the-box search and sort functionality.\n\n```php\n// In your Table definition\nuse Fnxsoftware\\FilamentAstrotomic\\Tables\\Columns\\TranslatableColumn;\nuse Filament\\Tables\\Table;\n\npublic static function table(Table $table): Table\n{\n    return $table\n        -\u003ecolumns([\n            TranslatableColumn::make('title')\n                -\u003esearchable()\n                -\u003esortable(),\n            // ... other columns\n        ]);\n}\n```\n\n### 3. Use `TranslatableEntry` in Infolists\n\nSimilarly, use `TranslatableEntry` in your infolists to display translated content that reacts to the `LocaleSwitcher`.\n\n```php\n// In your Infolist definition\nuse Fnxsoftware\\FilamentAstrotomic\\Infolists\\Components\\TranslatableEntry;\nuse Filament\\Infolists\\Infolist;\n\npublic static function infolist(Infolist $infolist): Infolist\n{\n    return $infolist\n        -\u003eschema([\n            TranslatableEntry::make('title'),\n            TranslatableEntry::make('content'),\n            // ... other entries\n        ]);\n}\n```\n\n## 🚀 Single Locale Optimization \u0026 Customization\n\n### Automatic Grid View\nWhen your application or a specific tenant only has **one locale** active, `TranslatableTabs` will automatically switch its layout to a standard **Grid**.\n\nThis removes the unnecessary tab bar, rendering the fields directly. This provides a cleaner UI for single-language contexts without requiring code changes.\n\n### Forcing Tabs Layout\nIf you prefer to always show the language tabs (even when only one locale is available), you can force the layout using one of two methods:\n\n#### 1. Global Configuration\nForce tabs globally for all `TranslatableTabs` components in your `AdminPanelProvider`:\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\FilamentAstrotomicPlugin;\n\npublic function panel(Panel $panel): Panel\n{\n    return $panel\n        // ...\n        -\u003eplugin(\n            FilamentAstrotomicPlugin::make()\n                -\u003eforce() // Always show tabs\n        );\n}\n```\n\n#### 2. Per-Component Configuration\nForce tabs on a specific component:\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Schemas\\Components\\TranslatableTabs;\n\nTranslatableTabs::make('translations')\n    -\u003eforce() // Always show tabs for this specific component\n    -\u003elocaleTabSchema(fn (TranslatableTab $tab) =\u003e [\n        // ...\n    ])\n```\n\n---\n\n### Custom Locales for Switcher\nYou can now define specific locales for the `LocaleSwitcher` action, overriding the global or tenant configurations. This is useful if specific resources or pages only support a subset of languages.\n\n```php\nuse Fnxsoftware\\FilamentAstrotomic\\Actions\\LocaleSwitcher;\n\n// Pass a list of locale codes (labels generated automatically)\nLocaleSwitcher::make()\n    -\u003elocales(['en', 'fr']);\n\n// Or pass custom labels\nLocaleSwitcher::make()\n    -\u003elocales([\n        'en' =\u003e 'English (US)',\n        'fr' =\u003e 'Français (France)',\n    ]);\n```\n\n## Advanced Usage\n\n### Custom Locales Per-Resource\n\nOverride the `getTranslatableLocales()` method in your resource to specify a different set of locales than the global configuration.\n\n```php\npublic static function getTranslatableLocales(): array\n{\n    return ['en', 'fr'];\n}\n```\n\n### Modal Forms\n\nTo use translatable fields inside modal actions (like an `EditAction` on a table row), you must correctly mutate the data.\n\n```php\nuse App\\Models\\Post;\nuse Filament\\Tables\\Actions\\EditAction;\n\n-\u003eactions([\n    EditAction::make()-\u003emutateRecordDataUsing(function (Post $record, array $data) {\n        return static::mutateTranslatableData($record, $data);\n    }),\n])\n```\n\n### Nested Relationship Support\n\nBoth `TranslatableColumn` and `TranslatableEntry` fully support displaying, searching, and sorting translated attributes on nested relationships using dot notation.\n\n**`TranslatableColumn` with a relationship:**\n\nThe column will display the country's name, and the search and sort functionality will correctly filter and order the `governorates` table based on the name of the related country.\n\n```php\n// In your GovernorateResource table\nTranslatableColumn::make('country.name')\n    -\u003elabel('Country')\n    -\u003esearchable()\n    -\u003esortable(),\n```\n\n**`TranslatableEntry` with a relationship:**\n\nThe entry will display the translated name of the related country on the governorate's view page.\n\n```php\n// In your GovernorateResource infolist\nTranslatableEntry::make('country.name')\n    -\u003elabel('Country'),\n```\n\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Credits\n\n-   **Original Author:** [Oleksandr Moik (cactus-galaxy)](https://github.com/oleksandr-moik)\n-   **Filament v4 Fork:** [Alary Dorian (Doriiaan)](https://github.com/Doriiaan)\n-   **Current Maintainer:** [Fnx-Software](https://github.com/fnx-software)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnx-software%2Ffilament-astrotomic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnx-software%2Ffilament-astrotomic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnx-software%2Ffilament-astrotomic/lists"}