Automattic / Automattic/jetpack

Jetpack-boost: Don't use _n() to distinguish between singular and plural

Open
#27,672 18 comments 0 reactions 0 assignees View on GitHub
[Focus] i18n [Plugin] Boost [Pri] Low Bug Triaged
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

### Impacted plugin

Boost

### Steps to Reproduce

When I was checking some translations for -boost, I noted that the plugin is using _n() incorrectly.

ref: https://plugins.trac.wordpress.org/browser/jetpack-boost/tags/1.5.4/app/assets/dist/jetpack-boost.js#L9
"Please follow the troubleshooting steps below for the page."//"Please follow the troubleshooting steps below for each of the pages."
or
"This page timed out:"//"These pages timed out:".

The function _n() should ONLY be used to correctly handle word forms etc for strings that include a number, and NOT to generically distinguish between singular and plural.

You can correct this in two different ways.
Either just make a logical check in your code, like (pseudo-code):
if 1==n then echo "This page timed out:" else echo "These pages timed out:"

OR include the value of n in the string (if it adds any value):
"The following &d page timed out"//"The following &d pages timed out"

If you want more background, then I've got this article: https://gsm.fjellner.com/hints-about-i18n-let-your-code-to-shine-all-over-the-world/

### A clear and concise description of what you expected to happen.

_No response_

### What actually happened

_No response_

### Browser

Google Chrome/Chromium, Mozilla Firefox, Microsoft Edge, Apple Safari, iOS Safari, Android Chrome

### Other information

_No response_

### Platform (Simple, Atomic, or both?)

_No response_

### Reproducibility

Intermittent

### Severity

_No response_

### Available workarounds?

_No response_

### Workaround details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the referenced app/assets/dist/jetpack-boost.js file and inspect the _n() calls for the two page and timeout messages. Trace each call to its source before changing it, then verify that plural handling is used only where the translated string includes a number and that the resulting messages remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php, wordpress
Domain
internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.