laravel-lang/status-generator
Dev tool for Laravel Lang that generates locale status by creating missing locales and downloading/copying translation files from Laravel projects (framework, laravel, jetstream). Provides CLI commands to create locales and fetch sources from URLs/paths.
Run vendor/bin/lang to explore available commands. Start with these essentials:
Initialize missing locales (e.g., for es, fr):
vendor/bin/lang create --locale=es
Or generate all missing locales at once:
vendor/bin/lang create
Check translation status (identify missing/translated keys):
vendor/bin/lang status
Output: A table showing translation coverage per locale (e.g., en, es).
Sync keys (update missing translations from source files):
vendor/bin/lang sync
First Use Case: After adding a new language file (e.g., resources/lang/es/auth.php), run lang sync to detect and add missing keys from en to es.
CI/CD Pipeline
Add to phpunit.yml or GitHub Actions:
- name: Sync translations
run: vendor/bin/lang sync
- name: Validate status
run: vendor/bin/lang status --format=json | jq -e '.missing == 0'
Local Development
# After pulling upstream Laravel updates
vendor/bin/lang download --url=https://github.com/laravel/framework/archive/refs/heads/10.x.zip --project=framework --ver=10.x --copy=lang
vendor/bin/lang sync
Automated Translation Drafts
vendor/bin/lang translate --locale=es --key=validation.required
.lang-status.php (see config quirks).--path to target specific files (e.g., resources/views):
vendor/bin/lang sync --path=resources/views/auth
vendor/bin/lang download --url=https://github.com/laravel/laravel/archive/refs/heads/10.x.zip --project=laravel --ver=10.x --copy=lang --only-copy
trans_choice Support: Automatically detects pluralization keys (e.g., validation.max.string).vendor/, node_modules/) by default.Locale Creation Without English
Running lang create fails if resources/lang/en/ doesn’t exist. Fix: Manually create en/ or use --force (if supported in future versions).
Key Detection False Positives
Ternary operators (?:) or complex strings may trigger false matches. Tip: Use --debug to inspect parsed keys:
vendor/bin/lang sync --debug
Google Translate API Limits
The translate command uses Google’s free tier. Tip: Cache results in storage/app/translations/ to avoid rate limits.
Path Conflicts
Downloading from --copy=lang may overwrite existing files. Tip: Use --only-copy to bypass key lookups:
vendor/bin/lang download --url=... --only-copy
-v for verbose output:
vendor/bin/lang sync -v
lang status reports errors, manually validate JSON/PHP syntax in resources/lang/.Custom Key Parsers
Extend LaravelLang\StatusGenerator\Parsers\Parser to handle project-specific syntax (e.g., custom translation helpers).
Post-Sync Hooks
Use Laravel’s commands event to trigger actions after lang sync:
// app/Providers/EventServiceProvider.php
protected $listen = [
'Illuminate\Console\Events\ArtisanStarting' => [
\App\Listeners\PostSyncHook::class,
],
];
Config Overrides
Create .lang-status.php in your project root to customize:
return [
'skip_paths' => ['resources/views/vendor/'],
'default_locale' => 'pt_BR',
];
--locale=es,fr to translate multiple locales at once:
vendor/bin/lang translate --locale=es,fr --key=validation.unique
Laravel\Lang\StatusGenerator\Services\LocaleService directly in custom commands for programmatic access.resources/lang/ to .gitignore and commit only synced files via:
vendor/bin/lang sync && git add resources/lang/
How can I help you explore Laravel packages today?