Skip to content

Incorrect use of _n() in tags/3.4.0/includes/admin/plugins.php #1488

@tobifjellner

Description

@tobifjellner

...3.4.0/includes/admin/plugins.php says:
_n( 'Failed to query WordPress.org Plugin Directory for the following plugin:', 'Failed to query WordPress.org Plugin Directory for the following plugins:', count( $errors ), 'performance-lab' )

and

esc_html( _n( 'The following error occurred:', 'The following errors occurred:', count( $error_messages ), 'performance-lab' ) ) . '</p>' .

_n() should never be used to split between generic singular and plural, The purpose of this function is to make it possible to create grammatically correct translations for strings that contain an integer in the strings, even for languages with quite complicated deflection rules when numbers are used.

If you're expecting _n() to nicely provide two strings, you'll be surprised. Slavic languages typically have three translations for every string pair with _n(), Arabic has six (6!) translations for every occurrence of _n(), and Japanese has only one translated string (when a number is used in a string, they won't change anything else in the string to reflect whether it's singular or plural, although they DO have means to indicate general plural...

This can be fixed in two ways.

  1. Either make these normal strings and split between singular vs. plural with simple code, or
  2. Make sure to include the number of plugins or the number of errors in the strings.

The same error may be present elsewhere in the plugin. I just happened to stumble upon these occurrences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature is broken

    Type

    No type

    Projects

    Status

    Done 😃

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions