Skip to main content
Translate your Laravel application to multiple languages at once, saving time and ensuring consistency across all your supported languages.

Translating to All Languages

By default, running translate without the --language option translates to all languages configured in your project.

Setup: Define Your Languages

First, ensure your config/ai-translations.php lists your supported languages:
config/ai-translations.php
<?php

return [
    'languages' => ['en', 'es', 'fr', 'de', 'it', 'pl', 'pt'],
];

Translate Everything

Run the command without specifying a language:
php artisan translate --name=messages
Output:
AI Translator
Source: en
Languages: es, fr, de, it, pl, pt
Domains: messages

Translating from en to es: messages
5 missing keys found: welcome, goodbye, dashboard.title, dashboard.stats, settings.profile

Translating in 1 chunks... (attempt #1 of 3)
████████████████████ 100%

Generated translations for messages from en to es:
welcome: "Bienvenido a nuestra aplicación"
goodbye: "Gracias por usar nuestro servicio"
dashboard.title: "Panel de Control"
...

Writing translations for messages from en to es

Translating from en to fr: messages
5 missing keys found: welcome, goodbye, dashboard.title, dashboard.stats, settings.profile

Translating in 1 chunks... (attempt #1 of 3)
████████████████████ 100%

Generated translations for messages from en to fr:
welcome: "Bienvenue dans notre application"
goodbye: "Merci d'utiliser notre service"
dashboard.title: "Tableau de bord"
...

Writing translations for messages from en to fr

# Continues for de, it, pl, pt...

Translating to Specific Languages

Use the --language option to translate to specific languages only.

Single Language

php artisan translate --language=es

Multiple Languages (Comma-Separated)

php artisan translate --language=es,fr,de
Output:
AI Translator
Source: en
Languages: es, fr, de
Domains: auth, validation, messages

Translating from en to es: auth
Translating from en to es: validation
Translating from en to es: messages

Translating from en to fr: auth
Translating from en to fr: validation
Translating from en to fr: messages

Translating from en to de: auth
Translating from en to de: validation
Translating from en to de: messages
When translating multiple files to multiple languages, the command processes each file for each language sequentially, ensuring consistent context.

Skipping Languages

Use --skip-languages to exclude specific languages from translation:
php artisan translate --skip-languages=es,fr
This translates to all configured languages except Spanish and French. Example Use Case: You’ve manually edited Spanish and French translations and don’t want them overwritten.

Translating Multiple Files

Combine multi-language translation with multiple files for maximum efficiency.

Translate All Files to All Languages

php artisan translate
This translates all files in your source language directory to all configured languages.

Translate Specific Files to Multiple Languages

php artisan translate --name=auth,validation,messages --language=es,fr,de
Output:
AI Translator
Source: en
Languages: es, fr, de
Domains: auth, validation, messages

# Translates:
# - auth.php to es, fr, de
# - validation.php to es, fr, de  
# - messages.php to es, fr, de

Skip Specific Files

php artisan translate --skip-names=validation
Translates all files except validation.php.

Changing the Source Language

By default, the source language is your application’s locale (config('app.locale')). You can specify a different source language:
php artisan translate --base-language=de --language=en,es,fr
This translates from German to English, Spanish, and French.
php artisan translate --base-language=de --language=en

Complete Example: Multi-Language Workflow

Here’s a complete workflow for managing translations across multiple languages:
1

Validate All Languages

First, check which languages need updates:
php artisan translate:validate
Output:
Checking translations...
Source: en
Languages: es, fr, de, it, pl, pt
Domains: auth, validation, messages

+------------------+--------------+
| Domain           | Missing Keys |
+------------------+--------------+
| de/auth          |            |
| de/messages      | 3            |
| de/validation    |            |
| es/auth          |            |
| es/messages      | 3            |
| es/validation    |            |
| fr/auth          |            |
| fr/messages      | 3            |
| fr/validation    |            |
| it/auth          |            |
| it/messages      |            |
| it/validation    |            |
| pl/auth          |            |
| pl/messages      | 5            |
| pl/validation    |            |
| pt/auth          |            |
| pt/messages      |            |
| pt/validation    |            |
+------------------+--------------+
indicates the file doesn’t exist yet for that language.
2

Translate All Missing Keys

Update all languages at once:
php artisan translate
This will:
  • Translate missing keys in de/messages, es/messages, fr/messages, pl/messages
  • Create new files for it/* and pt/*
3

Validate Again

Confirm all translations are complete:
php artisan translate:validate
Output:
+------------------+--------------+
| Domain           | Missing Keys |
+------------------+--------------+
| de/auth          |            |
| de/messages      |            |
| de/validation    |            |
| es/auth          |            |
| es/messages      |            |
| es/validation    |            |
| fr/auth          |            |
| fr/messages      |            |
| fr/validation    |            |
| it/auth          |            |
| it/messages      |            |
| it/validation    |            |
| pl/auth          |            |
| pl/messages      |            |
| pl/validation    |            |
| pt/auth          |            |
| pt/messages      |            |
| pt/validation    |            |
+------------------+--------------+

Performance Tips

When translating to many languages during development, use --fast to speed up the process:
php artisan translate --fast
This uses a faster LLM model. For production, run without --fast for higher quality.
Instead of translating everything at once, translate file by file:
php artisan translate --name=messages
php artisan translate --name=auth
php artisan translate --name=validation
This gives you more control and allows you to validate each file before moving to the next.
Add a validation step to your CI/CD pipeline:
.github/workflows/translations.yml
- name: Validate translations
  run: php artisan translate:validate
This ensures PRs don’t introduce missing translations.

Advanced Options Combination

Combine options for powerful workflows:
php artisan translate \
  --name=messages,auth \
  --language=es,fr,de \
  --base-language=en \
  --skip-languages=fr \
  --fast
This command:
  • Translates messages.php and auth.php
  • From English
  • To Spanish and German (skipping French)
  • Using the fast model

Next Steps

Basic Translation

Learn the basics of translating files

Partial Updates

Update only missing keys in existing files

Configuration

Configure language settings and LLM providers

Validation

Learn more about translation validation

Build docs developers (and LLMs) love