{"id":27145460,"url":"https://github.com/elegantengineeringtech/laravel-translator","last_synced_at":"2026-04-02T23:43:08.122Z","repository":{"id":244965534,"uuid":"816339762","full_name":"ElegantEngineeringTech/laravel-translator","owner":"ElegantEngineeringTech","description":"A Laravel Translations Manager with powerful features: Translate and Proofread using AI, Find missing and dead translations...","archived":false,"fork":false,"pushed_at":"2025-12-10T21:24:55.000Z","size":322,"stargazers_count":60,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-11T08:47:09.121Z","etag":null,"topics":["laravel","laravel-translation","laravel-translation-manager","localization","localization-tool","php","translation-management","translations"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ElegantEngineeringTech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"ElegantEngineeringTech"}},"created_at":"2024-06-17T14:40:44.000Z","updated_at":"2025-12-10T21:24:34.000Z","dependencies_parsed_at":"2024-06-18T17:55:25.936Z","dependency_job_id":"a2fcf97c-d635-4547-b69d-78e34f56d42f","html_url":"https://github.com/ElegantEngineeringTech/laravel-translator","commit_stats":null,"previous_names":["elegantengineeringtech/laravel-translator"],"tags_count":84,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/ElegantEngineeringTech/laravel-translator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantEngineeringTech%2Flaravel-translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantEngineeringTech%2Flaravel-translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantEngineeringTech%2Flaravel-translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantEngineeringTech%2Flaravel-translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElegantEngineeringTech","download_url":"https://codeload.github.com/ElegantEngineeringTech/laravel-translator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantEngineeringTech%2Flaravel-translator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29730662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-translation","laravel-translation-manager","localization","localization-tool","php","translation-management","translations"],"created_at":"2025-04-08T09:48:40.008Z","updated_at":"2026-03-04T01:18:16.431Z","avatar_url":"https://github.com/ElegantEngineeringTech.png","language":"PHP","funding_links":["https://github.com/sponsors/ElegantEngineeringTech"],"categories":[],"sub_categories":[],"readme":"# All-in-One Translations Manager for Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/elegantly/laravel-translator.svg?style=flat-square)](https://packagist.org/packages/elegantly/laravel-translator)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/ElegantEngineeringTech/laravel-translator/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/ElegantEngineeringTech/laravel-translator/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/ElegantEngineeringTech/laravel-translator/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/ElegantEngineeringTech/laravel-translator/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/elegantly/laravel-translator.svg?style=flat-square)](https://packagist.org/packages/elegantly/laravel-translator)\n\n![Laravel Translator](https://repository-images.githubusercontent.com/816339762/eefcad09-87ad-484e-bcc4-5759303dc4b6)\n\nEasily manage all your Laravel translation strings with powerful features:\n\n- **Translate** strings into other languages using OpenAI, Claude, Gemini or custom services.\n- **Proofread** translations to fix grammar and syntax automatically (using OpenAI, Claude, Gemini or custom service).\n- **Find missing** translation strings across locales.\n- **Detect unused** translation keys in your codebase.\n- **Sort** translations in natural order.\n- **Import \u0026 Export** translations in a CSV file.\n\n---\n\n## Try Laratranslate – A Powerful UI for Managing Translations\n\n[![Laratranslate](https://elegantly.dev/assets/laratranslate/opengraph.jpg)](https://elegantly.dev/laratranslate/)\n\n---\n\n# Table of Contents\n\n1. [How does it work?](#how-does-it-work)\n1. [Installation](#installation)\n1. [Configuring the Driver](#configuring-the-driver)\n1. [Configuring the Locales](#configuring-the-locales)\n    - [Automatic Detection](#automatic-detection)\n    - [Manual Setup](#manual-setup)\n1. [Configuring the Code Scanner](#configuring-the-code-scanner)\n    - [Requirements](#requirements)\n    - [Included Paths](#included-paths)\n    - [Excluded Paths](#excluded-paths)\n    - [Ignored Translation Keys](#ignored-translation-keys)\n1. [Sorting and Formatting](#sorting-and-formatting)\n    - [CLI Commands](#cli-commands)\n    - [Using Code](#using-code)\n1. [Automatic Translation](#automatic-translation)\n    - [Configuring Prism](#configuring-prism)\n    - [Using Claude](#using-claude)\n    - [Using Gemini](#using-gemini)\n    - [CLI Translation](#cli-translation)\n    - [Programmatic Translation](#programmatic-translation)\n1. [Proofreading Translations](#proofreading-translations)\n    - [CLI Proofreading](#cli-proofreading)\n    - [Programmatic Proofreading](#programmatic-proofreading)\n1. [Identifying Untranslated Translations](#identifying-untranslated-translations)\n    - [CLI Usage](#cli-usage)\n    - [Programmatic Usage](#programmatic-usage)\n1. [Detecting Missing Translations](#detecting-missing-translations)\n    - [CLI Usage](#cli-usage-1)\n    - [Programmatic Usage](#programmatic-usage-1)\n1. [Detecting Dead Translations](#detecting-dead-translations)\n    - [CLI Usage](#cli-usage-2)\n    - [Programmatic Usage](#programmatic-usage-2)\n1. [Export to a CSV](#export-to-a-csv)\n    - [CLI Usage](#cli-usage-3)\n    - [Programmatic Usage](#programmatic-usage-3)\n1. [Import from a CSV](#import-from-a-csv)\n    - [CLI Usage](#cli-usage-4)\n    - [Programmatic Usage](#programmatic-usage-4)\n\n## How does it work?\n\nThis package will directly modify your translation files like `/lang/en/messages.php` or `/lang/fr.json` for example.\n\nBoth `PHP` and `JSON` files are supported.\n\nAdvanced features like dead translations detection will scan your entire codebase to find unused translation strings.\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require elegantly/laravel-translator --dev\n```\n\nAdd the following line to your `.gitignore` file:\n\n```\nstorage/.translator.cache\n```\n\nPublish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=\"translator-config\"\n```\n\n---\n\n## Configuring the Driver\n\nThis package uses a driver-based architecture. By default, it supports two standard drivers: PHP and JSON.\n\n- Use the `PHP` driver if you store your translation strings in `.php` files, such as `/lang/en/message.php`.\n- Use the `JSON` driver if you store your translation strings in `.json` files, such as `/lang/fr.json`.\n\nYou can also create custom drivers for alternative storage methods, such as a database.\n\nSet the default driver in the configuration file:\n\n```php\nuse Elegantly\\Translator\\Drivers\\PhpDriver;\n\nreturn [\n    /**\n     * Possible values: 'php', 'json', or a class-string implementing Driver.\n     */\n    'driver' =\u003e PhpDriver::class,\n\n    // ...\n];\n```\n\n\u003e [!NOTE]\n\u003e All features are supported in both the PHP and JSON drivers.\n\n## Configuring the Locales\n\n### Automatic Detection\n\nBy default, this package will attempt to determine the locales defined in your application by scanning your `lang` directory.\n\nYou can customize this behavior in the configuration file.\n\n```php\nuse Elegantly\\Translator\\Support\\LocaleValidator;\n\nreturn [\n    // ...\n    'locales' =\u003e LocaleValidator::class,\n    // ...\n];\n```\n\n### Manual Setup\n\nTo set the locales manually, use the following configuration:\n\n```php\nreturn [\n    // ...\n    'locales' =\u003e ['en', 'fr', 'es'],\n    // ...\n];\n```\n\n---\n\n## Configuring the Code Scanner\n\nService: `searchcode`.\n\nFeatures:\n\n- [Detecting Missing Translations](#detecting-missing-translations)\n- [Detecting Dead Translations](#detecting-dead-translations)\n\nBoth the detection of dead and missing translations rely on scanning your code.\n\n- **Missing translations** are keys found in your codebase but missing in translation files.\n- **Dead translations** are keys defined in your translation files but unused in your codebase.\n\n### Requirements\n\nAt the moment, this package can only scan the following files:\n\n- `.php`\n- `.blade.php`\n\n\u003e [!NOTE]\n\u003e If you use a React or Vue frontend, it would not be able to scan those files, making this feature irrelevant.\n\nThe default detector uses `nikic/php-parser` to scan all your `.php` files, including the Blade ones.\n\nIn order to be able to detect your keys, you will have to use one of the following Laravel function:\n\n- `__(...)`,\n- `trans(...)`\n- `trans_choice(...)`\n- `\\Illuminate\\Support\\Facades\\Lang::get(...)`\n- `\\Illuminate\\Support\\Facades\\Lang::has(...)`\n- `\\Illuminate\\Support\\Facades\\Lang::hasForLocale(...)`\n- `\\Illuminate\\Support\\Facades\\Lang::choice(...)`\n- `app('translator')-\u003eget(...)`\n- `app('translator')-\u003ehas(...)`\n- `app('translator')-\u003ehasForLocale(...)`\n- `app('translator')-\u003echoice(...)`\n\nOr one of the following Laravel Blade directive:\n\n- `@lang(...)`\n\nHere is some example of do's and don'ts:\n\n```php\n__('messages.home.title'); // ✅ 'messages.home.title' is detected\n\nforeach(__('messages.welcome.lines') as $line){\n    // ✅ 'messages.welcome.lines' and all of its children are detected.\n}\n\n$key = 'messages.home.title';\n__($key); // ❌ no key is detected\n```\n\n### Included Paths\n\nSpecify paths to scan for translation keys. By default, both `.php` and `.blade.php` files are supported.\n\n```php\nreturn [\n    'searchcode' =\u003e [\n        'paths' =\u003e [\n            app_path(),\n            resource_path(),\n        ],\n    ],\n];\n```\n\n### Excluded Paths\n\nExclude irrelevant paths for optimized scanning, such as test files or unrelated directories.\n\n```php\nreturn [\n    'searchcode' =\u003e [\n        'excluded_paths' =\u003e [\n            'tests'\n        ],\n    ],\n];\n```\n\n### Ignored Translation Keys\n\nIgnore specific translation keys:\n\n```php\nreturn [\n    'searchcode' =\u003e [\n        'ignored_translations' =\u003e [\n            'countries', // Ignore keys starting with 'countries'.\n        ],\n    ],\n];\n```\n\n---\n\n## Sorting and Formatting\n\n### CLI Commands\n\nSort translations with the default driver:\n\n```bash\nphp artisan translator:sort\n```\n\nSpecify a driver for sorting:\n\n```bash\nphp artisan translator:sort --driver=json\n```\n\n### Using Code\n\nSort translations programmatically with the default driver:\n\n```php\nuse Elegantly\\Translator\\Facades\\Translator;\n\nTranslator::sortTranslations(locale: 'fr');\n```\n\nSpecify a driver:\n\n```php\nTranslator::driver('json')-\u003esortTranslations(locale: 'fr');\n```\n\n---\n\n## Automatic Translation\n\nService: `translate`.\n\nBefore translating, configure a translation service. The package supports:\n\n- **Prism (prism-php/prism)**\n- Any Prism provider (OpenAI, Anthropic/Claude, Gemini, Ollama, ...)\n\nCustom translation services can also be implemented.\n\n### Configuring Prism\n\nEnable Prism as your translation service in `config/translator.php`:\n\n```php\nreturn [\n    // ...\n\n    'translate' =\u003e [\n        'service' =\u003e 'prism',\n        // ...\n    ],\n];\n```\n\nChoose the provider/model used by the translator:\n\n```php\nreturn [\n    // ...\n\n    'services' =\u003e [\n        'prism' =\u003e [\n            'provider' =\u003e env('TRANSLATOR_PRISM_PROVIDER', 'openai'),\n            'model' =\u003e env('TRANSLATOR_PRISM_MODEL', 'gpt-4.1-mini'),\n        ],\n    ],\n\n    // ...\n];\n```\n\nPrism itself reads provider credentials from `config/prism.php`.\n\nIf you haven't published the Prism config yet:\n\n```bash\nphp artisan vendor:publish --tag=prism-config\n```\n\n### Using Claude\n\nTo translate with Claude via Prism, set the provider to `anthropic` and pick a Claude model:\n\n```php\nreturn [\n    // ...\n\n    'services' =\u003e [\n        'prism' =\u003e [\n            'provider' =\u003e 'anthropic',\n            'model' =\u003e 'claude-3-7-sonnet-latest',\n        ],\n    ],\n\n    // ...\n];\n```\n\n\u003e 💡 **Note:** Ensure your `ANTHROPIC_API_KEY` is configured in `config/prism.php` (or set in your `.env`).\n\n### Using Gemini\n\nTo translate with Gemini via Prism, set the provider to `gemini` and pick a Gemini model:\n\n```php\nreturn [\n    // ...\n\n    'services' =\u003e [\n        'prism' =\u003e [\n            'provider' =\u003e 'gemini',\n            'model' =\u003e 'gemini-2.0-flash',\n        ],\n    ],\n];\n```\n\n\u003e 💡 **Note:** Ensure your `GEMINI_API_KEY` is configured in `config/prism.php` (or set in your `.env`).\n\n### CLI Translation\n\nDisplay all keys defined in the source locale (English) but not translated in the target (French):\n\n```bash\nphp artisan translator:untranslated en fr\n```\n\nSpecify a driver:\n\n```bash\nphp artisan translator:untranslated en fr --driver=json\n```\n\nAdd a new locale (French) with their translations from a source (English):\n\n```bash\nphp artisan translator:add-locale fr en --translate\n```\n\nTranslate all keys from a source locale (English) into a target locale (French).\nBy default, it only translates missing keys:\n\n```bash\nphp artisan translator:translate en fr\n```\n\nForce re-translation of all keys (overwrites existing target values):\n\n```bash\nphp artisan translator:translate en fr --force\n```\n\nTranslate using smaller/larger chunks (defaults to `10`):\n\n```bash\nphp artisan translator:translate en fr --chunk=25\n```\n\nTranslate using a specific driver:\n\n```bash\nphp artisan translator:translate en fr --driver=json\n```\n\n### Programmatic Translation\n\nTranslate translations programmatically with the default driver:\n\n```php\nTranslator::translateTranslations(\n    source: 'en',\n    target: 'fr',\n    keys: ['validation.title', ...]\n);\n```\n\nSpecify a driver for translation:\n\n```php\nTranslator::driver('json')-\u003etranslateTranslations(\n    source: 'en',\n    target: 'fr',\n    keys: ['My Title', ...]\n);\n```\n\n---\n\n## Proofreading Translations\n\nService: `proofread`.\n\nProofreading corrects the grammar and syntax of your translation strings.\n\nThis package ships with a Prism-based proofreading service (`prism-php/prism`), and custom services can also be implemented.\n\nEnable it by setting `translator.proofread.service` to `prism`, and configure Prism as described in [Configuring Prism](#configuring-prism).\n\n### CLI Proofreading\n\nProofread all strings in the target locale (English).\n\n```bash\nphp artisan translator:proofread en\n```\n\n### Programmatic Proofreading\n\nProofread translations with the default driver:\n\n```php\nTranslator::proofreadTranslations(\n    locale: 'fr',\n    keys: ['auth.email', ...]\n);\n```\n\nSpecify a driver:\n\n```php\nTranslator::driver('json')-\u003eproofreadTranslations(\n    locale: 'fr',\n    keys: ['My Title', ...]\n);\n```\n\n---\n\n## Identifying Untranslated Translations\n\nFind keys defined in one locale but missing in another.\n\n### CLI Usage\n\nDisplay all keys defined in the source locale (English) but not in the target locale (French).\n\n```bash\nphp artisan translator:untranslated en fr\n```\n\n### Programmatic Usage\n\n```php\nTranslator::getUntranslatedTranslations(source: 'en', target: 'fr');\n```\n\n---\n\n## Detecting Missing Translations\n\nService: `searchcode`.\nConfiguration: [Configuring the Code Scanner](#configuring-the-code-scanner)\n\nMissing translations are keys found in your codebase but missing in translation files.\n\n### CLI Usage\n\nFind keys defined in your codebase but missing in your locale (English) using your default driver:\n\n```bash\nphp artisan translator:missing en\n```\n\nSpecify a driver:\n\n```bash\nphp artisan translator:missing en --driver=json\n```\n\nAdd the missing keys to your driver:\n\n```bash\nphp artisan translator:missing en --sync\n```\n\n### Programmatic Usage\n\n```php\nTranslator::getMissingTranslations(locale: 'en');\n```\n\n---\n\n## Detecting Dead Translations\n\nService: `searchcode`.\nConfiguration: [Configuring the Code Scanner](#configuring-the-code-scanner)\n\nDead translations are keys defined in your locale (English) but unused in your codebase.\n\n### CLI Usage\n\n```bash\nphp artisan translator:dead en\n```\n\n### Programmatic Usage\n\n```php\nTranslator::getDeadTranslations(locale: 'fr');\n```\n\n## Export to a CSV\n\nService: `exporter`\n\nExport all your translation strings to a CSV file in the following format:\n\n| key                 | en    | fr        |\n| ------------------- | ----- | --------- |\n| messages.auth.login | Login | Connexion |\n\n### CLI Usage\n\n```bash\nphp artisan translator:export /path/to/my/file.csv\n```\n\n### Programmatic Usage\n\n```php\n$path = Translator::exportTranslations('/path/to/my/file.csv');\n```\n\n## Import from a CSV\n\nService: `exporter`\n\nImport translation strings from a CSV file. Ensure your CSV follows the format below:\n\n| key                 | en    | fr        |\n| ------------------- | ----- | --------- |\n| messages.auth.login | Login | Connexion |\n\n### CLI Usage\n\n```bash\nphp artisan translator:import /path/to/my/file.csv\n```\n\n### Programmatic Usage\n\n```php\n$translations = Translator::importTranslations('/path/to/my/file.csv');\n```\n\n## Testing\n\nRun tests using:\n\n```bash\ncomposer test\n```\n\n---\n\n## Changelog\n\nSee the [CHANGELOG](CHANGELOG.md) for recent updates.\n\n---\n\n## Contributing\n\nCheck the [CONTRIBUTING](CONTRIBUTING.md) guide for details.\n\n---\n\n## Security Vulnerabilities\n\nReport security vulnerabilities via GitHub or email.\n\n---\n\n## Credits\n\n- [Quentin Gabriele](https://github.com/QuentinGab)\n- [All Contributors](../../contributors)\n\n---\n\n## License\n\nThis package is licensed under the MIT License. See the [License File](LICENSE.md) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantengineeringtech%2Flaravel-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felegantengineeringtech%2Flaravel-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantengineeringtech%2Flaravel-translator/lists"}