-
Notifications
You must be signed in to change notification settings - Fork 823
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
text collector doesn't collect when parameters are passed as a variable #11268
Comments
current fix if you have the issue, if you can live with a silly syntax ;-) $ImCollectedAgain = _t('PageController.ImNOTCollected', 'test {some}', [...$var]); |
I don't know that this is a bug so much as a desired enhancement. The text collector relies on what is currently a pretty crude hand-made static analysis. The capability to figure out what's in a variable would be a new capability, I think. |
well, at least it could complain or make some kind of error. Or at least be documented here https://docs.silverstripe.org/en/5/developer_guides/i18n/#usage-in-php-files |
it also doesn't work on this silverstripe-framework/src/Dev/BulkLoader.php Line 175 in 754ac17
due to $type being a variable and not parsed correctly (but that is easily fixable by replacing . $type . by {type} and pass the type as context |
@GuySartorelli i'm working on a PR that works with the relevant use cases. I think it makes a lot of sense in many places to be able to use variables as either the second or third argument |
Module version(s) affected
5.x
Description
the method collectFromCode doesn't collect if the third argument is a variable instead of a plain array. This makes using _t not very practical if you reuse injection arguments in multiple strings.
eg from my project
Here is some code
is never collected
works fine
How to reproduce
In a controller, have
Run text collector
=> ImNOTCollected is not there
Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)PRs
The text was updated successfully, but these errors were encountered: