Open lekoala opened 3 weeks ago
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 at the moment it fails silently even though i have a _t function even a regex would do a better job :)
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)