zdearo/laravel-auto-translate

A Laravel package for auto translate strings.

v1.0.1 2025-05-24 06:47 UTC

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:

  1. Scan your application for translation strings
  2. Create a new_strings_{locale}.json file with the found strings
  3. 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:

  1. Only merge strings that have translations
  2. Merge all strings (including empty translations)
  3. 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.