[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:16:19 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        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 https://core.trac.wordpress.org/changeset/41812/ introduced a (probably)
 incorrect use of _n()

 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
 customize-nav-menus.php?marks=587#L587


 {{{
                 $this->manager->add_section( 'menu_locations', array(
                                 'title'       => _nx( 'View Location',
 'View All Locations', $num_locations, 'menu locations' ),
                                 'panel'       => 'nav_menus',
                                 'priority'    => 30,
                                 'description' => $description
                         ) );

 }}}

 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
 customize-nav-menus.php?marks=417#L417


 {{{
                                'locationsTitle'         => _n( 'Menu
 Location', 'Menu Locations', $num_locations ),

 }}}

 If the idea is to use these phrases ''without numbers'' then it´s better
 to simply translate the two phrases separately.

 When _n() is applied, you always need to include a count as a parameter in
 order for the function to pick the right form.
 But there´s single specific number that would always, positively, for any
 language, mean just "plural without number".

 So, _n() should be used only when the phrase contains the number that will
 lead to a certain form to be used. If it´s plain plural without number,
 then just the phrase should be translated as normally.
 (In the same way, even if you have a number, but it´s hardcoded, like
 "this will be checked within 72 hours", then you can safely leave the
 phrase like that, no need to use _n() if 72 isn´t a variable parameter!)

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


More information about the wp-trac mailing list