Find Hardcoded Text in Your Laravel App with Code Scanner
We've all been there: you're internationalizing a Laravel app and need to find every hardcoded string. You open your codebase and realize there are hundreds of files to check.
The Code Scanner changes that.
How It Works
One command scans your entire codebase:
php artisan translator:scan
That's it. The scanner analyzes your .blade.php and .php files, finding text that should be translated:
- Headings and button labels
- Form placeholders and attributes
- Error messages and notifications
- Any user-facing string
Smart Key Suggestions
The scanner doesn't just find text—it suggests translation keys based on context.
Found <h1>Welcome to our app</h1>?
Suggested key: home.headings.welcome
Each suggestion comes with a confidence score so you know which ones need review.
AI-Enhanced Analysis
Add the --ai flag for even smarter suggestions:
php artisan translator:scan --ai
The difference is significant:
| Original | Without AI | With AI |
|----------|------------|---------|
| "You did it John!" | you-did-it-john | congratulations with :name placeholder |
| "Hola María!" | hola-maria | greeting with :name placeholder |
AI detects dynamic content (names, numbers, dates) and converts them to proper placeholders automatically.
Review and Apply
After scanning, review suggestions in LangSyncer's web interface. Then apply the changes:
php artisan translator:apply
Your code transforms from:
<h1>Welcome to our app</h1>
<button>Submit</button>
To:
<h1>{{ __('home.headings.welcome') }}</h1>
<button>{{ __('buttons.submit') }}</button>
The Best Part
You can run scans as often as you want:
- After adding new features
- Before releases
- As part of code review
Never miss a hardcoded string again.