Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find missing translation strings in blade files #1822

Open
nerg4l opened this issue Jan 22, 2024 · 5 comments
Open

Find missing translation strings in blade files #1822

nerg4l opened this issue Jan 22, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@nerg4l
Copy link

nerg4l commented Jan 22, 2024

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')

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 Larastan/PHPStan.

@calebdw
Copy link
Contributor

calebdw commented Jan 22, 2024

Awesome!

However, this seems better suited for the Bladestan project which is already analyzing blade files. To the best of my knowledge (and I could be wrong), but Larastan does not report missing views.

@nerg4l
Copy link
Author

nerg4l commented Jan 22, 2024

Yes, my bad. The comment on Reddit misled me. I will close this PR and open one there. Thanks for the info.

@philbates35
Copy link

To the best of my knowledge (and I could be wrong), but Larastan does not report missing views.

It does actually:

https://github.com/larastan/larastan/blob/2.x/src/Types/ViewStringType.php

However it doesn't currently seem to be working properly, see #1607

@canvural
Copy link
Collaborator

Hi,

Yes this is possible with Larastan. I even had a working PR about this: #1456

Actually I would say this suits to Larastan more than Bladestan 😄 Because Bladestan compiles the blade files to PHP and then does static analysis. To do this task you do not need to compile the blade files. You can check the linked PR on how it works.

If you want, you can try to revive my linked PR and we can add this to Larastan. But it needs to be an optional rule disabled by default.

@nerg4l
Copy link
Author

nerg4l commented Jan 22, 2024

I will keep this issue open because it looks like a possible enhancement. Also, I will try to find some time to check the linked PRs and code. If I'm enthusiast enough, I can add it to both library.

@nerg4l nerg4l reopened this Jan 22, 2024
@canvural canvural added enhancement New feature or request help wanted Extra attention is needed labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants