- How do I install Laravel Translations Checker in my project?
- Add it as a dev dependency via Composer: `composer require --dev larswiegers/laravel-translations-checker`. No additional setup is required unless you need custom exclusions, which can be configured in `config/translation-checker.php`.
- Does this package work with Laravel 12?
- Yes, the package supports Laravel 8.0+ and has been tested up to Laravel 12.x. It’s fully compatible with PHP 8.0+ and integrates seamlessly with Laravel’s native translation system.
- Can I exclude vendor or test language files from the check?
- Absolutely. Use the `--excludedDirectories` flag (e.g., `--excludedDirectories=lang/vendor`) or configure `excluded_directories` in the config file. You can also exclude specific languages like `en` or `test` via `exclude_languages`.
- Will this tool catch dynamically generated translation keys (e.g., `trans('key.'.$dynamicSuffix)`)?
- No, this tool only checks static translation files (PHP/JSON). Dynamic keys generated at runtime (e.g., via variables or custom logic) won’t be detected. For those, consider static analysis tools or manual review.
- How do I run the checker in CI/CD to block merges if translations are missing?
- Add the command to your CI workflow (e.g., GitHub Actions) with strict mode: `php artisan translations:check`. To fail fast, ensure the command exits with a non-zero status on missing translations. Example: `- name: Check translations run: php artisan translations:check`.
- Does the package support non-standard translation directories (e.g., `app/Translations`)?
- Yes, use the `--directory` flag to specify a custom path, like `php artisan translations:check --directory=app/Translations`. This is useful for projects with non-standard file structures or monorepos.
- Can I exclude specific file extensions (e.g., only check JSON files)?
- Yes, use `--excludedFileExtensions` to filter by extension. For example, `--excludedFileExtensions=php` will only check JSON files. This is also configurable in `config/translation-checker.php` under `excluded_file_extensions`.
- What happens if some languages have partial translations (e.g., missing a few keys)?
- The tool reports all missing keys per language but doesn’t flag partial translations (e.g., a language with 90% of keys present). For partial checks, you’d need a custom solution or post-processing script.
- Is there a performance impact in large projects (e.g., 50+ languages or 10K+ files)?
- The tool is lightweight but may slow down with very large translation sets due to filesystem I/O. Test with a subset of files in CI first. For massive projects, consider running it in parallel or during off-peak hours.
- How does this integrate with localization tools like Crowdin or Lokalise?
- This package is a standalone validator for your Laravel translation files. Use it alongside Crowdin/Lokalise to catch missing keys *before* exporting to your project. It won’t conflict but can complement by enforcing completeness in your codebase.