Skip to main content

Overview

The translate command automatically translates missing translation keys from your base language to one or more target languages using AI.

Syntax

php artisan translate [options]

Options

--fast
flag
Use a faster LLM model for translations. This option sacrifices some precision for improved speed.
--interactive
flag
Enable interactive mode. This allows you to review and re-translate each file individually, with the option to re-translate files even when no missing keys are found.
--skip-names
string
Skip specific translation files. Provide a comma-separated list of file names to exclude from translation.Example: --skip-names=validation,pagination
--skip-languages
string
Skip specific target languages. Provide a comma-separated list of language codes to exclude from translation.Example: --skip-languages=fr,de
--name
string
Translate only specific file(s). Provide a comma-separated list of file names (without extension) to translate.Example: --name=messages,validation
--language
string
Translate to specific language(s) only. Provide a comma-separated list of language codes.Example: --language=es,fr,de
--base-language
string
The source language to translate from. Defaults to the app.locale configuration value.Example: --base-language=en
--after
string
Internal option for resuming translations after a specific point.
--lang-dir
string
Custom base path for translation files. Defaults to Laravel’s lang_path() directory.Example: --lang-dir=/custom/path/lang

Examples

php artisan translate

Output Example

AI Translator
Source: en
Languages: es, fr, de
Domains: messages, validation

Translating from en to es: messages
15 missing keys found: welcome.title, welcome.subtitle, ...
Translating in 3 chunks... (attempt #1 of 3) ████████████████████ 100%

Generated translations for messages from en to es:
welcome.title: "Bienvenido"
welcome.subtitle: "Comience su viaje con nosotros"
...

Writing translations for messages from en to es

Translating from en to fr: messages
15 missing keys found: welcome.title, welcome.subtitle, ...

Behavior

  • Missing Keys Detection: The command automatically detects which translation keys exist in your base language but are missing in target languages
  • Chunked Processing: Translations are processed in chunks with automatic retries (up to 3 attempts)
  • Progress Tracking: Real-time progress bars show translation progress for each file
  • No Missing Keys: When no missing keys are found, the file is skipped (unless in interactive mode)
  • Automatic Writing: Translated keys are automatically merged with existing translations and written to disk
The command preserves existing translations and only adds missing keys. It will never overwrite existing translation values unless you explicitly re-translate in interactive mode.

Build docs developers (and LLMs) love