tomatophp/
filament-translations-gpt
g4t.io

Using AI to Manage Translations in Laravel

29 stars by Paul Redmond

Translations Manager extension to use ChatGPT openAI to auto translate your __(), trans() fn

README from tomatophp/filament-translations-gpt Open on GitHub →

Screenshot

Filament Translations GPT

Dependabot Updates PHP Code Styling Tests Latest Stable Version License Downloads

Translations Manager extension to use ChatGPT openAI to auto translate your __(), trans() fn

Version Compatibility

Plugin Filament Laravel PHP
1.x 3.x 10.x / 11.x 8.1+
4.x (v4 branch) 4.x 11.x / 12.x 8.2+
5.x 5.x 12.x / 13.x 8.2+

Screenshots

GPT Action GPT Modal

Installation

before install this package you need to have Translation Manager installed and configured

composer require tomatophp/filament-translations-gpt

after install your package please run this command

php artisan filament-translations-gpt:install

finally register the plugin on /app/Providers/Filament/AdminPanelProvider.php

->plugin(\TomatoPHP\FilamentTranslationsGpt\FilamentTranslationsGptPlugin::make())

Usage

now you need to add the following to your .env file:

OPENAI_API_KEY=
OPENAI_ORGANIZATION=
# optional
OPENAI_MODEL=gpt-4o-mini
OPENAI_BASE_URL=https://api.openai.com/v1

Any OpenAI compatible chat completions API works, for example Groq:

OPENAI_BASE_URL=https://api.groq.com/openai/v1
OPENAI_MODEL=llama-3.1-8b-instant

now you need to clear you cache

php artisan config:clear

Click the GPT button on the translations page and pick a language. A queued job sends the English text of your translations to the API in chunks (chunk_size in the config, 50 by default), saves the answers and notifies you when it is done. Run a queue worker (php artisan queue:work) for the job to run. Words prefixed with : are kept as placeholders.

Without OPENAI_API_KEY nothing is sent: the job only notifies you that the key is missing. If the API answers with an error, you are notified and the job fails.

The action follows the translation policy of the Translation Manager: it needs the create ability.

Publish Assets

you can publish config file by use this command

php artisan vendor:publish --tag="filament-translations-gpt-config"

you can publish languages file by use this command

php artisan vendor:publish --tag="filament-translations-gpt-lang"

Testing

if you like to run PEST testing just use this command

composer test

Code Style

if you like to fix the code style just use this command

composer format

PHPStan

if you like to check the code by PHPStan just use this command

composer analyse

Other Filament Packages

Checkout our Awesome TomatoPHP

More from the ecosystem

marcreichel/
laya-php
g4t.io
3 53

LayaPHP: Self-Hosted Text Classification for PHP and Laravel

Classify text in PHP without an LLM bill: typed decisions in 100+ languages, self-hosted. Laravel-ready SDK for Laya, a Jev AI alternative.

ai classification decision-engine
marcreichel/laya-php via Laravel News
Josh-Dovey/
postcodes-laravel
g4t.io
5 9

Postcodes for Laravel: GB Postcode Lookup and Geography Data

Postcodes for Laravel adds typed GB postcode lookups, validation, geography data, distance searches, and test fakes through the GB Postcodes API.

Josh-Dovey/postcodes-laravel via Laravel News
RedberryProducts/
mailbox-for-laravel
g4t.io
4 115

Mailbox for Laravel: Preview and Test Rendered Email

Mailbox for Laravel captures outgoing mail in a local dashboard and lets you test rendered HTML, recipients, and attachments with fluent assertions.

RedberryProducts/mailbox-for-laravel via Laravel News