edeoliv/gpt-translate
Laravel package to generate and translate JSON language files using OpenAI ChatGPT. Scans PHP/JS/TS/Vue for __(), @lang(), trans(), etc., builds a base locale, then translates to other languages with optional context, exclusions, and model selection.
__(), @lang(), trans()), ensuring compatibility with existing i18n workflows.__() calls), which may miss edge cases (e.g., dynamic strings, JS/TS files).resources/lang/ structure, requiring no schema changes.trans() helpers.{name} placeholders) may not translate correctly without explicit context.es_ES vs. es_MX)? The package only supports language codes.trans() helpers, lang files, and localization middleware.laravel-localization or spatie/laravel-translation-loader.@lang directive or trans in Blade).__() calls.Mockery or Vapor for local dev).en → es) for non-critical sections (e.g., blog content)..json/.php lang files with dynamically generated ones (via php artisan gpt:translate).config/app.php changes).__() calls (e.g., configure Babel/Webpack to preserve them)..env).openai.php with model preferences (e.g., gpt-3.5-turbo vs. gpt-4).php artisan gpt:generate to scan and create a base en.json (or use existing files).php artisan gpt:translate es to generate Spanish translations.GptTranslateService).gpt-3.5-turbo changes).gpt-translate label to GitHub issues for tracking.429 Too Many Requests).gpt:translate job).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| OpenAI API downtime | Translations unavailable | Fallback to cached translations or static files. |
| Rate limit exceeded | Partial translations | Implement exponential backoff + queue retries. |
| High translation costs | Budget overrun | Monitor usage; switch to GPT-3.5 for bulk. |
| Poor translation quality | User confusion/inaccuracies | Human review for critical content; refine prompts. |
| Dynamic strings missed | Untranslated placeholders | Manual review of JS/TS files; add context hints. |
trans() helpers and the package’s Artisan commands.// Good
'gpt_prompt' => 'Translate "{string}" to Spanish
How can I help you explore Laravel packages today?