PHPackages                             mateffy/ai-translations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. mateffy/ai-translations

ActiveLibrary[Localization &amp; i18n](/categories/localization)

mateffy/ai-translations
=======================

Manage your Laravel translations using AI! Auto translate and more!

2.2.0(5mo ago)8901MITPHP

Since May 15Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/Capevace/ai-translations-for-laravel)[ Packagist](https://packagist.org/packages/mateffy/ai-translations)[ RSS](/packages/mateffy-ai-translations/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (6)Used By (0)

Automatic AI Translations for Laravel 🤖
=======================================

[](#automatic-ai-translations-for-laravel-)

> Automatically translate your Laravel application's language files with high accuracy and context awareness using the power of LLMs.
>
> Translate to completely new languages or keep your existing language files up-to-date, without completely re-generating the full file.
>
> This package also includes tools for validation of the files, maintaining quality and consistency.

[![](./docs/screenshot-1.webp)](./docs/screenshot-1.webp)

✨ Features
----------

[](#-features)

- 🔄 Automatic translation of Laravel language files
- 🌐 Translate to new languages or update existing ones without full regeneration
- 🧠 Context-aware translations
- 🔍 Smart detection of missing translations
- 💬 Interactive chat mode for translation refinement
- ✅ Validation tools for quality assurance

🚀 Usage
-------

[](#-usage)

### Step 1: Install the package

[](#step-1-install-the-package)

```
composer require mateffy/ai-translations
```

### Step 2: Configure your LLM provider

[](#step-2-configure-your-llm-provider)

This package supports many different LLM providers using [`mateffy/llm-magic`](https://github.com/capevace/llm-magic). To use this package, you will need to configure your LLM provider, preferably Anthropic or OpenAI.

To do this, add the following variables to your `.env` file. For other LLM configurations see the [`llm-magic` documentation](https://github.com/capevace/llm-magic).

```
AI_TRANSLATIONS_MODEL=anthropic/claude-3.5-sonnet # default
ANTHROPIC_API_KEY=your-api-key

# or if you are using OpenAI:

AI_TRANSLATIONS_MODEL=openai/gpt-4o
OPENAI_API_KEY=your-api-key
OPENAI_ORGANIZATION=your-organization # optional
```

### Step 3: Translate your files!

[](#step-3-translate-your-files)

You are now good to go. Use the `translate` update or create a language file, and use the `translate:validate` command to check for missing translations.

```
$ php artisan translate

AI Translator
Model: anthropic/claude-3-haiku-20240307
Source: de
Languages: cn, en, es, fr, it, pl
Domains: test

Translating from de to en: test
Generated translations for test from de to en:
okay_what_about_this.key: Okay, what about this?
okay_what_about_this.key2: Okay, what about this?
okay_what_about_this.key3: Okay, what about this?
...
```

🛠️ Commands
-----------

[](#️-commands)

### Translate Files

[](#translate-files)

```
php artisan translate
```

This command translates your language files to all configured languages. It:

1. Detects missing translations
2. Uses AI to generate appropriate translations
3. Writes the translations to your language files

**Options:**

- `--name=` : Translate a specific file only
- `--language=` : Translate to a specific language only
- `--base-language=` : Source language (defaults to `app.locale`)
- `--fast` : Use a faster LLM (less precise)
- `--interactive` : Interactively translate the files by allowing re-translation each file
- `--skip-names=` : Skip the given files
- `--skip-languages=` : Skip the given languages

### Validate Translations

[](#validate-translations)

```
php artisan translate:validate
```

Performs comprehensive validation of your translations by checking for missing keys.

**Options:**

- `--name=` : Validate specific file
- `--language=` : Validate specific language
- `--base-language=` : Source language for validation

```
$ php artisan translate:validate

AI Translator: Validation
Model: anthropic/claude-3-haiku-20240307
Source: de
Languages: cn, en, es, fr, it, pl
Domains: test

Checking test in es...

No missing translations for test in es

Checking test in fr...

****************************************************
*     Missing translations for `test` in `fr`:     *
****************************************************

+---------------+-------------+
| Key           | Value       |
+---------------+-------------+
| something_new | Etwas neues |
| testing       | Testen      |
+---------------+-------------+
...
```

🔧 How It Works
--------------

[](#-how-it-works)

The TranslationFile class reads Laravel's PHP language files into memory, preserving their nested array structure while allowing access through dot notation (e.g., 'auth.failed' =&gt; 'message'). It handles both reading existing translations and creating new language files.

When translating, the system always provides the full source and target language files to the LLM to ensure it has complete context about the existing translations and their relationships. This helps maintain consistency in terminology and style across the application.

The LLM then returns only the translated strings that need to be added or updated, using dot notation. This selective return is efficient as it allows precise updates without regenerating the entire translation file. These dot-notated translations are automatically merged into the existing translation structure, handling both new keys and updates to existing ones.

⚙️ Configuration
----------------

[](#️-configuration)

Configuration options in `config/ai-translations.php`:

```
return [
    // Supported languages (optional)
    'languages' => ['en', 'de', 'fr', 'es'],

    // Additional configuration options can be added here
];
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit pull requests.

📄 License
---------

[](#-license)

This package is open-source software licensed under the [MIT license](./LICENSE).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Total

5

Last Release

154d ago

Major Versions

1.0.1 → 2.0.02025-12-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/e572442281b0c1b6e8e8f966cc908161a66c4c822e950ff278f8f90dc4f2d2cd?d=identicon)[mateffy](/maintainers/mateffy)

---

Top Contributors

[![Capevace](https://avatars.githubusercontent.com/u/10093858?v=4)](https://github.com/Capevace "Capevace (32 commits)")

---

Tags

aianthropicautomationgeminilaravellaravel-packagellmlocalizationopenaiphptranslation

### Embed Badge

![Health badge](/badges/mateffy-ai-translations/health.svg)

```
[![Health](https://phpackages.com/badges/mateffy-ai-translations/health.svg)](https://phpackages.com/packages/mateffy-ai-translations)
```

###  Alternatives

[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

590244.8k1](/packages/askdkc-breezejp)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.3k](/packages/typicms-base)[statikbe/laravel-filament-chained-translation-manager

A translation manager tool for Laravel Filament, that makes use of the Laravel Chained Translator.

92108.7k](/packages/statikbe-laravel-filament-chained-translation-manager)[kenepa/translation-manager

Manage your application's translation strings in Filament.

14583.6k2](/packages/kenepa-translation-manager)[outerweb/filament-translatable-fields

Filament integration for spatie/laravel-translatable

3582.9k8](/packages/outerweb-filament-translatable-fields)[elegantly/laravel-translator

All on one translations management for Laravel

6216.9k](/packages/elegantly-laravel-translator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
