Download the PHP package martin6363/filament-ai-translator without Composer
On this page you can find all versions of the php package martin6363/filament-ai-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martin6363/filament-ai-translator
More information about martin6363/filament-ai-translator
Files in martin6363/filament-ai-translator
Package filament-ai-translator
Short Description AI-powered auto-translation for Spatie Translatable fields in Filament 4 and 5
License MIT
Homepage https://github.com/martin6363/filament-ai-translator
Informations about the package filament-ai-translator
Filament AI Translator
AI-powered, one-click translations for Filament form fields โ built for Spatie Translatable and locale-suffixed layouts alike.
Translate content across locales in seconds using Google Gemini โ directly inside your Filament admin panel.
โจ Features
| Feature | Description |
|---|---|
| ๐ Dual-Mode Integration | Works with Spatie Translatable JSON/array field states and separate locale-suffixed columns such as title_en, title_am, title_ru. |
| ๐ง Smart Suffix & Layout Detection | Detects sibling locale fields inside Tabs, Sections, or any nested Filament layout. Uses Filament's Set Utility and Livewire state paths to populate related fields automatically. |
| ๐ Resilient AI Failover | If the primary Gemini model is under high demand, the package gracefully rotates through gemini-2.5-flash, gemini-2.0-flash, and gemini-1.5-flash to keep translations flowing. |
| ๐จ Adaptive UI | Adds a sleek translate action as a suffix on affix-capable fields (TextInput, Select, โฆ) or as a hint on complex editors like RichEditor. |
| โก Filament 4 & 5 Ready | Built on the modern Filament\Contracts\Plugin architecture with a clean ->aiTranslate() macro on any form Field. |
| ๐ Polished UX | Loading, success, and failure states are surfaced through native Filament notifications. |
๐ธ Demo
Screenshot (recommended: Tab layout with
title_en/title_am/title_rufields).
Example: translate from the English tab and instantly populate Russian sibling fields.
Example: Spatie translatable
๐ฆ Installation
Install the package via Composer:
Publish the configuration file:
Publish the language files (optional โ customize notification and action labels):
Register the plugin in your Filament panel provider:
Note: The package auto-registers via Laravel package discovery. You only need to add the plugin to your panel.
๐ Environment Setup
Add your Google Gemini credentials to .env:
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Yes | API key from Google AI Studio. |
GEMINI_MODEL |
No | Primary model. Defaults to gemini-2.0-flash. Fallback models are tried automatically on high-demand errors. |
Security: Never commit API keys to version control. Restrict keys in Google AI Studio, rotate them regularly, and use environment-specific secrets in production (e.g. encrypted env, vault, or CI secrets).
โ๏ธ Configuration
After publishing, customize config/filament-ai-translator.php:
The default_locales array is used when ->aiTranslate() is called without explicit locales. Align these with your Spatie Translatable setup or your _locale field suffixes.
๐ Usage
Attach ->aiTranslate() to any Filament form field. The macro is registered on Filament\Forms\Components\Field and works with TextInput, Textarea, RichEditor, and more.
Zero-configuration (implicit locales)
Call ->aiTranslate() without arguments to use config('filament-ai-translator.default_locales'):
How it behaves:
- Spatie / JSON fields โ reads the active form locale, translates into all other configured locales, and merges the JSON state.
- Suffixed fields (
title_en) โ detects the locale from the field name and fills sibling fields (title_am,title_ru) in the same form โ including fields inside Tabs or Sections.
Explicit locales (custom)
Override the default locale list per field:
Spatie Translatable (JSON / array state)
Ideal with spatie/laravel-translatable and plugins such as Lara Zeus Spatie Translatable:
- Switch to your source locale using your translatable locale switcher.
- Type content in the active locale.
- Click the language action on the field.
- Save โ translations are written into the multi-locale state.
Separate fields layout (locale suffixes + Tabs)
Perfect when each locale has its own database column (title_en, title_am, title_ru):
Filament 5 note:
Tabslive underFilament\Schemas\Components\Tabs. In Filament 4, you may use the equivalent layout component from your installed Filament version.
When translating from title_en, the plugin:
- Detects base name
titleand source localeen. - Calls Gemini for targets
amandru. - Sets
title_amandtitle_ruvia Filament's Set Utility โ even when those fields live in other tabs.
๐งฉ How it works (under the hood)
๐ Translating UI strings
Publish translations to customize action labels and notifications:
Files are published to lang/vendor/filament-ai-translator/.
๐งช Requirements
- PHP
^8.2or higher - Laravel
^11.0,^12.0, or^13.0 - Filament
^4.0or^5.0 - google-gemini-php/client
^2.0 - A valid Google Gemini API key
๐ Changelog
Please see CHANGELOG.md for a history of releases and notable changes.
Unreleased
- Dual-mode translation (Spatie JSON + locale-suffixed fields)
- Gemini model failover for high-demand scenarios
- Adaptive suffix / hint action placement
- Filament 4 & 5 plugin architecture
๐ค Contributing
Contributions are welcome and appreciated.
Please keep PRs focused, follow existing code style, and include tests where applicable.
๐ Credits
- Martin Khachatryan โ Author & maintainer
- Filament โ Admin panel framework
- Spatie Laravel Translatable โ Multi-locale Eloquent attributes
- Google Gemini PHP Client โ Community Gemini SDK
- All contributors
๐ License
The MIT License (MIT). See LICENSE for more information.
Made with โค๏ธ for the Filament community ยท GitHub
All versions of filament-ai-translator with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
filament/filament Version ^4.0|^5.0
google-gemini-php/client Version ^2.0