Download the PHP package fnx-software/filament-astrotomic without Composer
On this page you can find all versions of the php package fnx-software/filament-astrotomic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fnx-software/filament-astrotomic
More information about fnx-software/filament-astrotomic
Files in fnx-software/filament-astrotomic
Package filament-astrotomic
Short Description Filament support for Astrotomic's Laravel Translatable package.
License MIT
Homepage https://github.com/fnx-software/filament-astrotomic
Informations about the package filament-astrotomic
Filament Astrotomic Translations
This package is an extension for Filament v5 and laravel-translatable to easily manage multilingual content in your admin panel.
For Filament v4, use an older compatible release/tag.
This is an enhanced fork of doriiaan/filament-astrotomic and the original cactus-galaxy/filament-astrotomic, updated for Filament 5 and introducing powerful new features like a reactive LocaleSwitcher and dedicated components for displaying translated content.
Installation
You can install the package via Composer:
Publish the configuration for astrotomic/laravel-translatable:
Configure the locales your app should use in config/translatable.php:
Setup
Adding the Plugin to a Panel
Register the plugin in your Panel Provider:
Customizing the Main Locale (Optional)
By default, the main locale is taken from your config/translatable.php file. You can override this dynamically when registering the plugin.
Set a static main locale:
Set a dynamic main locale (e.g., from database settings):
Customizing the Available Locales (Optional)
By default, the available locales are loaded from your config/translatable.php file.
You 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).
Set a static locales list:
Basic Usage
1. Preparing Your Model
Make your Eloquent model translatable as described in the laravel-translatable documentation.
2. Preparing Your Resource
Apply the ResourceTranslatable trait to your Filament resource class:
3. Making Resource Pages Translatable
You must also apply the corresponding translatable trait to each of your resource's pages.
List Page:
Create Page:
Edit Page:
View Page:
Form Components
TranslatableTabs for Localized Fields
To manage translations for your model's attributes, use the TranslatableTabs component. It automatically creates a tab for each locale.
Customizing Field Labels
To 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.
Custom Locales Per TranslatableTabs Instance
By default, TranslatableTabs will use the locales configured for the plugin (or the translatable.locales config).
If 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:
TranslatableSelect for Relationships
The 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.
This will correctly display the country names in the current locale, and the search functionality will also work on the translated names.
Displaying Translated Content Reactively
This 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.
1. Add the LocaleSwitcher Action
Add the LocaleSwitcher to the header actions of your List and View pages.
2. Use TranslatableColumn in Tables
The TranslatableColumn automatically displays the translation for the selected locale and provides out-of-the-box search and sort functionality.
3. Use TranslatableEntry in Infolists
Similarly, use TranslatableEntry in your infolists to display translated content that reacts to the LocaleSwitcher.
🚀 Single Locale Optimization & Customization
Automatic Grid View
When your application or a specific tenant only has one locale active, TranslatableTabs will automatically switch its layout to a standard Grid.
This removes the unnecessary tab bar, rendering the fields directly. This provides a cleaner UI for single-language contexts without requiring code changes.
Forcing Tabs Layout
If 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:
1. Global Configuration
Force tabs globally for all TranslatableTabs components in your AdminPanelProvider:
2. Per-Component Configuration
Force tabs on a specific component:
Custom Locales for Switcher
You 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.
Advanced Usage
Custom Locales Per-Resource
Override the getTranslatableLocales() method in your resource to specify a different set of locales than the global configuration.
Modal Forms
To use translatable fields inside modal actions (like an EditAction on a table row), you must correctly mutate the data.
Nested Relationship Support
TranslatableColumn and TranslatableEntry support displaying translated attributes on nested relationships using dot notation.
Search support is available for relationship paths handled by the component.
Sorting support is currently limited and should be considered supported for direct attributes and simple relationship cases only.
TranslatableColumn with a relationship:
The 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.
TranslatableEntry with a relationship:
The entry will display the translated name of the related country on the governorate's view page.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Original Author: Oleksandr Moik (cactus-galaxy)
- Filament v4 Fork: Alary Dorian (Doriiaan)
- Current Maintainer: Fnx-Software
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of filament-astrotomic with dependencies
astrotomic/laravel-translatable Version ^11.16
filament/filament Version ^5.0
filament/forms Version ^5.0
filament/tables Version ^5.0
spatie/laravel-package-tools Version ^1.15.0