TomasVotruba / bladestan

PHPStan analysis for Blade templates
https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/
MIT License
298 stars 13 forks source link

Find missing translation strings in blade files #94

Open nerg4l opened 9 months ago

nerg4l commented 9 months ago

Hello,

I recently developed a package (coding-socks/lost-in-translation) which is able to scan Blade files to identify translation strings and report if the translation for that string is missing from a locale.

u/boreasaurus on Reddit said the following:

It would be amazing if somehow this functionality existed in larastan, as that is already reporting errors for e.g. view('some.unknown.view')

In larastan/larastan#1822 I was informed that they probably meant this package and not Larastan.

My package provides a lost-in-translation:find {locale} artisan command which reads all blade files, compiles them to PHP, converts them to tokens, and then finds the relevant nodes in the AST (Abstract syntax tree). As far as I know, this is similar to how static analysis tools work.

I'm not sure if I will have enough time in the upcoming days but I would happily work on adding this feature if you think it's a good addition. However, I might require some guidance on where to start because I'm not familiar enough with PHPStan.

AJenbo commented 9 months ago

For performance reasons this tool might need a rewrite where it works more like what you describe. Currently it injections the compiled code as their analyser scans each file