laravel-ai-translator  by kargnas

AI-powered translation for Laravel language files

Created 1 year ago
250 stars

Top 100.0% on SourcePulse

GitHubView on GitHub
Project Summary

kargnas/laravel-ai-translator

This package automates the translation of Laravel language files using AI models like Claude, GPT, and Gemini, significantly reducing manual effort and improving translation quality. It targets Laravel developers seeking to streamline internationalization, offering context-aware translations and advanced management features for language assets.

How It Works

The tool leverages various AI providers (Anthropic Claude, OpenAI GPT, Google Gemini) to translate PHP and JSON language files. It analyzes translation keys for context, preserving variables, HTML tags, and pluralization rules. Advanced features include detecting and removing unused translation keys, cleaning existing translations, and supporting custom language styles for unique localization needs. Translations can be processed in parallel for efficiency.

Quick Start & Requirements

  • Primary install: composer require kargnas/laravel-ai-translator
  • Prerequisites: PHP 8.0+, Laravel 8.0+.
  • Configuration: Publish configuration (php artisan vendor:publish), set AI provider API keys (Anthropic, OpenAI, or Gemini) in .env, and configure config/ai-translator.php.
  • Usage: Commands include php artisan ai-translator:translate, php artisan ai-translator:translate-parallel, php artisan ai-translator:find-unused, php artisan ai-translator:clean, and php artisan ai-translator:translate-json.
  • Relevant Links: Anthropic Console, OpenAI Platform, Google AI Studio.

Highlighted Details

  • Supports multiple AI providers, with Anthropic Claude models strongly recommended for superior quality and context understanding.
  • Includes find-unused command to scan code (PHP, JS, Vue, Blade) and remove obsolete translation keys, with automatic backups.
  • Offers clean command to remove translations from locale files, preparing them for re-translation.
  • Enables custom language styles and regional dialects, alongside built-in options.
  • Handles both PHP array-based and root-level JSON language files.
  • Features parallel translation, visual logging with progress indicators, and token usage tracking.

Maintenance & Community

Created by Sangrak Choi. The repository includes links to articles by the creator discussing localization and the tool's development. No specific community channels (like Discord/Slack) or sponsorship details are listed in the README.

Licensing & Compatibility

Licensed under the MIT License (MIT), permitting commercial use and integration into closed-source projects.

Limitations & Caveats

The TODO list indicates planned improvements for strict translation validation (variables, pluralization) and replacing the regex-based XML parser. While OpenAI and Gemini are supported, the documentation strongly advises against using OpenAI for translations due to consistently inferior results compared to Claude.

Health Check
Last Commit

5 months ago

Responsiveness

1+ week

Pull Requests (30d)
0
Issues (30d)
0
Star History
2 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.