Skip to content

Add PhpLexer to support extraction from standard PHP files and Laravel Blade #1134

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WebCimes
Copy link

@WebCimes WebCimes commented May 5, 2025

Why am I submitting this PR

This PR introduces a PhpLexer to support extraction of translation keys from both Laravel Blade templates and standard PHP files.
It handles common translation function calls such as t('...'), __('...'), @lang('...'), and trans('...').
The lexer supports escaped quotes, avoids concatenated strings, and correctly processes nested translation functions.
All features are covered by unit tests to ensure compatibility with typical PHP usages.

Does it fix an existing ticket?

No

WebCimes added 2 commits May 5, 2025 09:48
- Implement tests for extracting single and multiple keys from translation functions.
- Support for custom function names in extraction.
- Handle extraction when additional parameters are present.
- Test extraction from nested functions.
- Validate extraction of keys with special syntax (%key and :key).
- Ensure correct handling of escaped characters in strings.
- Confirm that no exceptions are thrown on invalid PHP input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant