[wp-trac] [WordPress Trac] #42170: Incorrect use of _n() in /wp-includes/class-wp-customize-nav-menus.php

WordPress Trac noreply at wordpress.org
Tue Oct 10 19:38:41 UTC 2017


#42170: Incorrect use of _n() in /wp-includes/class-wp-customize-nav-menus.php
--------------------------+------------------------------
 Reporter:  tobifjellner  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Menus         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------
Changes (by felipeelia):

 * keywords:   => close


Comment:

 Hi @tobifjellner!

 This change is related to #42112.

 >If the idea is to use these phrases without numbers then it´s better to
 simply translate the two phrases separately.
 Yes, but we would have to include an `if` to test which one is needed,
 right?

 >When _n() is applied, you always need to include a count as a parameter
 in order for the function to pick the right form.
 That number is `$num_locations`, the third parameter passed in both cases.
 As the decision of which string to pick is made based on that value it
 doesn't have to be presented on the screen, at least not in this case.

 It's like the last part of
 [https://developer.wordpress.org/reference/classes/translations/translate_plural/
 translate_plural()] function. If the counter is 1 we need the singular
 form, if it's 2 or more we need the plural form

 {{{
 return 1 == $count? $singular : $plural;
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42170#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list