zdearo / laravel-auto-translate
A Laravel package for auto translate strings.
Fund package maintenance!
Adryel Dearo
Requires
- php: ^8.1
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
This package is auto-updated.
Last update: 2025-05-24 06:48:51 UTC
README
A Laravel package for extracting and managing translation strings in your Laravel applications. This package helps you identify untranslated strings in your codebase and manage translations for multiple languages.
Installation
You can install the package via composer in your Laravel project:
composer require zdearo/laravel-auto-translate
You can publish the config file with:
php artisan vendor:publish --tag="laravel-auto-translate-config"
Usage
Extract Translations
This command scans your Laravel application for translation strings and extracts them to a JSON file:
php artisan translations:extract {locale}
Replace {locale}
with your desired language code (e.g., en
, pt_BR
, es_ES
).
The command will:
- Scan your application for translation strings
- Create a
new_strings_{locale}.json
file with the found strings - Optionally merge the new strings into your existing translation file
Merge Translations
This command merges translated strings from new_strings_{locale}.json
to your main translation file:
php artisan translations:merge {locale}
The command offers three merge options:
- Only merge strings that have translations
- Merge all strings (including empty translations)
- Interactive mode: review each untranslated string
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Credits
License
The MIT License (MIT). Please see License File for more information.