Auto-detection (recommended)
By default, the package automatically detects languages from yourlang directory:
config/ai-translations.php
null, the package scans your Laravel application’s lang_path() directory and identifies all available language directories.
How auto-detection works
The package looks for language subdirectories in yourlang folder:
en, de, fr, and es.
Auto-detection is the recommended approach as it keeps your configuration in sync with your actual language files.
Manual configuration
You can explicitly specify which languages your application supports:config/ai-translations.php
When to use manual configuration
Manual configuration is useful when:- You want to translate to languages that don’t exist yet in your
langdirectory - You want to exclude certain language directories from translation
- You need strict control over which languages are processed
- You’re planning to add new languages and want them configured ahead of time
Language codes
Use standard ISO 639-1 language codes (2-letter codes) or locale codes:Base language
The base language (also called source language) is the language you’re translating from. By default, this is your application’s locale:config/app.php
- Your primary language isn’t English
- You want to translate from a different source language
- You’re maintaining translations in multiple directions
The base language should always be complete and accurate, as all other translations are generated from it.
Working with language files
Creating a new language
To add a new language to your application:- Manual configuration: Add the language code to the
languagesarray - Auto-detection: Create a new directory in your
langfolder
- Auto-detection
- Manual configuration
Translating specific languages
You can limit translations to specific languages:Validating languages
Check for missing translations in specific languages:Best practices
Keep your base language complete
Always ensure your base language (typicallyen) is complete and up-to-date:
Use auto-detection when possible
Auto-detection keeps your configuration simple and automatically adapts to your project structure:Group related translations
Organize your language files by domain:Validate before deploying
Always run validation before deploying to ensure all translations are complete:Examples
Multi-language application
config/ai-translations.php
European languages only
config/ai-translations.php
Adding Asian languages
config/ai-translations.php
LLM models generally handle Asian languages well, but always review translations for cultural appropriateness and context.
Next steps
Start translating
Learn how to translate your language files
Validate translations
Check for missing translations