- How do I install php-translation/extractor for Laravel projects?
- Run `composer require php-translation/extractor --dev` to install. The package includes a CLI tool at `vendor/bin/extractor`, ready for immediate use in Laravel 9+ or 10+ projects. No Laravel-specific configuration is needed for basic extraction.
- Does this package support Laravel 11’s new Blade syntax (e.g., @props directives)?
- As of now, Laravel 11’s newer Blade features like `@props` may not be fully parsed. Monitor the [GitHub issue tracker](https://github.com/php-translation/extractor/issues) for updates or use custom extraction rules if needed. Test with `--dry-run` to verify coverage.
- Can I use this extractor with PHP 8.3’s attribute groups or named arguments?
- The package supports PHP 8.3 via dynamic version parsing (`--php-version=8.3`), but experimental features like named arguments in attributes may require custom extraction rules. Run a dry test to check for false negatives in your codebase.
- What output formats does this package support for Laravel’s lang/ directory?
- It generates `.po`, `.json`, and `.xliff` files—ideal for Laravel’s `lang/` directory. Use flags like `--format=json` to match your translation workflow (e.g., Crowdin, Poedit). The default is `.po`, compatible with most Laravel localization tools.
- Will this slow down my CI/CD pipeline for large Laravel apps?
- Extraction can be slow for codebases >50K LOC. Mitigate this by running in parallel (e.g., split by directory) or caching results for unchanged files. For GitHub Actions, use `concurrency` controls to avoid bottlenecks.
- How does this handle Symfony forms or validation logic in Laravel?
- The package detects Laravel-specific patterns like `FormTypeInterface` (since v2.2.3) and Symfony 7+ constraints, reducing false positives in forms or validation logic. Test with `--dry-run` to confirm accuracy in complex validation rules.
- Can I customize extraction rules for project-specific translation patterns?
- Yes, use `ExtractionRule` classes to handle custom patterns (e.g., dynamic API translation keys). The package’s modular design allows overriding default parsers without modifying core logic.
- Does this work with Laravel’s Blade templates and Twig?
- It fully supports Blade and Twig 3+, including modern syntax like `{{ form_row(form) }}`. Fixes for Twig FilterExpressions (v2.2.1) and Symfony constraints (v2.1.0) ensure accurate parsing of template-based translations.
- Are there alternatives to this package for Laravel translation extraction?
- Alternatives include `laravel-lang` (Laravel-specific) or generic tools like `gettext`/`xgettext`. However, this package stands out for its Laravel/Symfony hybrid support, dynamic PHP version parsing, and CI/CD optimization—ideal for polyglot Laravel apps.
- How do I integrate this into a GitHub Actions workflow for automated extraction?
- Add a step like `vendor/bin/extractor --format=json --output=lang/en.json` to your workflow. Use `if: github.event_name == 'push'` to run only on pushes, and cache dependencies (`nikic/php-parser`) to speed up execution. Example: [GitHub Actions template](https://github.com/php-translation/extractor#ci-cd).