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.

CommentFileSizeAuthor
#2 potx-format_plural-2151527.patch5.73 KBherom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

BTW we should keep format_plural() support so long as it is in the codebase, people may invoke it still, so we should support it.

herom’s picture

Status: Active » Needs review
FileSize
5.73 KB

added 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?

Gábor Hojtsy’s picture

This 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 :).

Gábor Hojtsy’s picture

Version: 6.x-3.x-dev » 7.x-2.x-dev
Status: Needs review » Patch (to be ported)

Committed this to the 6.x-3.x branch, thanks!

  • Gábor Hojtsy committed 7c530c8 on 7.x-2.x
    Issue #2151527 by herom | Gábor Hojtsy: Support for formatPlural() in...

  • Gábor Hojtsy committed 7c530c8 on 7.x-3.x
    Issue #2151527 by herom | Gábor Hojtsy: Support for formatPlural() in...
SebCorbin’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Patch (to be ported) » Closed (fixed)

Ported to 7.x-3.x as it has been branched directly from 6.x-3.x