Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Extractor Laravel Package

php-translation/extractor

PHP Translation Extractor scans PHP and Blade source files for translatable strings, pulling calls such as __(), trans(), and @lang into structured translation files. It helps keep Laravel and Symfony language files in sync with your code and reduces missing or stale translations.

View on GitHub
Deep Wiki
Context7

php-translation/extractor scans your PHP source and Blade templates for translatable strings and pulls them into ready-to-translate files. Part of the php-translation suite, it recognizes common helpers like __(), trans(), and @lang, keeping your translation files in sync with your code without manual copying.

  • Supports Laravel, Symfony, and plain PHP projects
  • Extracts from Blade templates and PHP source files
  • Pluggable extractors for custom syntax
  • Exports to PHP, JSON, XLIFF, and YAML formats
Frequently asked questions about Extractor
How do I install php-translation/extractor in a Laravel project?
Install it as a development dependency with composer require php-translation/extractor --dev. Run vendor/bin/extractor with options such as --format=json --output=resources/lang/en/extracted.json. It is a CLI tool, so no service provider registration is required. Use it locally or in CI to scan your source files.
Does php-translation/extractor support Laravel Blade templates?
Yes, it parses Blade directives such as @lang and @choice, including dynamic Blade directives and @php blocks without modification. This lets you extract translatable strings from Blade views alongside PHP calls like __() and trans(). Validate extraction on a branch if you use newer Blade features such as inline imports or stacked sections.
Which Laravel and PHP versions are supported by php-translation/extractor?
The package is designed for modern Laravel and PHP projects, and host PHP version parsing in v2.3.2 supports PHP 8.1 through 8.3, which covers Laravel 10 and 11 projects. Projects on PHP below 8.1 or Symfony below 6 may need polyfill rules or a downgraded package version such as v2.0.x. Use the --php-version option to test extraction behavior for your target runtime.
How does php-translation/extractor detect translatable strings in PHP code?
It scans source code for common translation calls such as __(), trans(), and Symfony form or constraint messages, then generates keys for your localization workflow. It also supports concatenated labels and array placeholders added in v2.1.0, improving accuracy for dynamic strings. Complex PHP 8.2+ constructs or custom helpers may require custom extraction rules or manual review.
Can php-translation/extractor extract strings from JavaScript, TypeScript, or CSS files?
No, the package has no native support for JavaScript, TypeScript, or CSS files. It focuses on PHP and Laravel or Symfony translation calls, Blade templates, Twig filters, and form placeholders. For full-stack localization you will need a parallel tool such as i18next-scanner for frontend assets.
How do I integrate php-translation/extractor into CI/CD?
It is designed as a CLI tool, so you can run vendor/bin/extractor in GitHub Actions, Git hooks, or Laravel post-update-cmd scripts. A typical workflow step runs vendor/bin/extractor --format=json --output=resources/lang/en/extracted.json. For large codebases, consider incremental extraction of modified files or splitting directories to avoid slowing pipelines.
Will php-translation/extractor work with large Laravel codebases?
It can handle large codebases, but parsing 50K+ lines may slow CI pipelines. Mitigate by extracting only modified files, running extraction in parallel by directory, or scheduling it outside the critical path. Also log extraction failures so missing keys do not silently reach production.
What are the alternatives to php-translation/extractor for Laravel localization?
Alternatives include manual lang file maintenance, Laravel-specific extraction scripts, and frontend scanners like i18next-scanner for JavaScript and TypeScript assets. php-translation/extractor is useful when you want a CLI-focused PHP parser that supports Blade, __(), trans(), Symfony forms, and constraints. Pair it with translation management tools such as Crowdin or Lingui for team collaboration.
Is php-translation/extractor safe for production and how should it be maintained?
It is typically installed as a dev dependency and run in CI or local workflows rather than in production runtime. Maintenance should include auditing extraction rules after Laravel or PHP upgrades, especially for new Blade features and PHP 8.3+ syntax. Use --debug and composer why-not to validate compatibility and dependency conflicts before upgrading.
How do I test that extracted translation keys are correct?
Run extraction on a branch and compare the generated JSON with your existing resources/lang files before merging. Pair extraction with PestPHP or PHPUnit tests that assert required translation keys exist, and use --debug to investigate missed strings. Review dynamic or concatenated strings manually because custom PHP constructs may require extraction rule adjustments.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings