Skip to content
This repository was archived by the owner on Feb 22, 2026. It is now read-only.

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

Open
WebCimes wants to merge 2 commits intoi18next:masterfrom
WebCimes:master
Open

Add PhpLexer to support extraction from standard PHP files and Laravel Blade#1134
WebCimes wants to merge 2 commits intoi18next:masterfrom
WebCimes:master

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant