Problem/Motivation
#2111349: Move format_plural to the string translation service and format_interval to the date service. added formatPlural() as a method on the string translation service and #2149195: Replace format_plural with \Drupal::translation()->formatPlural() and #2079797: Provide a trait for $this->t() and $this->formatPlural() are working to add formatPlural() as methods to things, so it can be used as a local feature. Looking for format_plural() is not enough anymore.
Proposed resolution
The same code that looks for format_plural() should also recognise formatPlural() in parsing PHP. Probably a simple change :)
Remaining tasks
Fix code, write tests.
Comment | File | Size | Author |
---|---|---|---|
#2 | potx-format_plural-2151527.patch | 5.73 KB | herom |
Comments
Comment #1
Gábor HojtsyBTW we should keep format_plural() support so long as it is in the codebase, people may invoke it still, so we should support it.
Comment #2
herom CreditAttribution: herom commentedadded patch.
so, is this the right way to do this?
also, this would parse plain "formatPlural" calls for translation too. should we enforce the "->" token before "formatPlural"? or be even more specific?
Comment #3
Gábor HojtsyThis looks to me the right way yup. I'm not concerned for the global formatPlural() function (which will not exist) and that other methods may be called the same (which should not happen with this or with t() by convention :).
Comment #4
Gábor HojtsyCommitted this to the 6.x-3.x branch, thanks!
Comment #7
SebCorbin CreditAttribution: SebCorbin commentedPorted to 7.x-3.x as it has been branched directly from 6.x-3.x