ibrahimamasha / autotranslator
Automatically translate Laravel JSON files using AI or free tools.
Installs: 411
Dependents: 0
Suggesters: 0
Security: 0
Stars: 18
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/ibrahimamasha/autotranslator
Requires
- deeplcom/deepl-php: ^1.4
Suggests
- laravel/framework: Required for Laravel integration
This package is not auto-updated.
Last update: 2025-10-25 12:20:03 UTC
README
Laravel AutoTranslator is a simple Laravel package to automate translating your language files — ideal for bilingual projects like Arabic/English.
It scans your code for translation keys, fills in missing entries in lang/en.json, and auto-translates them into Arabic (lang/ar.json) using MyMemory or DeepL.
Features
- Scans Blade and PHP files for
__()and@lang()keys - Auto-generates
lang/en.jsonandlang/ar.json - Uses MyMemory by default (free, no API key)
- Fallback support for DeepL (requires API key, 500k characters/month free)
- Works with just two Artisan commands
Installation
composer require ibrahimamasha/autotranslator
Configuration (Optional)
Publish the config file:
php artisan vendor:publish --tag=config
Example config/autotranslator.php:
return [ 'source' => 'en', 'target' => 'ar', 'driver' => 'mymemory', // default: free, no key needed 'mymemory' => [ 'email' => env('MYMEMORY_EMAIL'), 'key' => env('MYMEMORY_KEY'), ], 'deepl' => [ 'key' => env('DEEPL_KEY'), // required if using DeepL ], ];
MyMemory is the default driver and works without an API key.
DeepL offers more accurate results, but requires an API key (500,000 free characters/month).
Usage
1. Create translation files
php artisan translate:setup
2. Scan and translate
php artisan translate:scan
Example
For this code:
__('Dashboard') @lang('No messages yet')
The package generates:
{
"Dashboard": "Dashboard",
"No messages yet": "No messages yet"
}
{
"Dashboard": "لوحة التحكم",
"No messages yet": "لا توجد رسائل بعد"
}
Author
Ibrahim Amasha
LinkedIn
GitLab
License
MIT License