ibrahimamasha/autotranslator

There is no license information available for the latest version (2.1.0) of this package.

Automatically translate Laravel JSON files using AI or free tools.

Installs: 409

Dependents: 0

Suggesters: 0

Security: 0

Stars: 18

Watchers: 0

Forks: 1

Open Issues: 0

pkg:composer/ibrahimamasha/autotranslator

2.1.0 2025-07-04 12:40 UTC

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.json and lang/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