WordPress.org

Making WordPress.org

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#1322 closed defect (fixed)

Missing plural forms for '%d people say it works.'

Reported by: SergeyBiryukov Owned by:
Milestone: Priority: normal
Component: Plugin Directory Keywords:
Cc:

Description

There are two similar strings in plugin directory:

  • '%d people say it works.' (without plural forms).
  • _n( '1 person says it works.', '%s people say it works.', ... ) (plural)

Not sure where the latter is used, but I see the former (without plural forms support) in the Compatibility block on Jetpack page.

The former string should be removed, and the latter should be used instead.

Attachments (2)

meta-1322.png (6.9 KB) - added by SergeyBiryukov 4 years ago.
meta-1322.2.png (34.7 KB) - added by SergeyBiryukov 3 years ago.

Download all attachments as: .zip

Change History (14)

#1 follow-up: @coffee2code
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

The former is part of the JS related to the compatibility feature. The JS allows the "it works" and "it's broken" text under the 'Compatibility' dropdowns on individual plugin pages to update dynamically as the dropdown values are changed. It is passed translated strings for singular and plural forms for 'works' and 'broken'.

Here's the actual code defining those strings (ignore the deprecated function use...):

worksTextN = [ '<?php echo js_escape( __( '1 person says it works.', 'wporg' ) ); ?>', '<?php echo js_escape( __( '%d people say it works.', 'wporg' ) ); ?>' ],
brokeTextN = [ '<?php echo js_escape( __( "1 person says it's broken.", 'wporg' ) ); ?>', '<?php echo js_escape( __( "%d people say it's broken.", 'wporg' ) ); ? >' ];

You can load an individual plugin's page and see the output. The JS has to decide which plural form to use, so it needs both strings of each type.

The latter string translation you noted is the text used for the initial output of the 'Compatibility' section.

Seems like the current approach is a legitimate use for non-plural forms support.

Feel free to reopen with recommendations for changing the JS or for passing context to translators if it's beneficial to do so.

#2 in reply to: ↑ 1 ; follow-up: @SergeyBiryukov
4 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to coffee2code:

You can load an individual plugin's page and see the output. The JS has to decide which plural form to use, so it needs both strings of each type.

I see the correct form in the page source, but then it gets replaced with an incorrect form from JS.

So essentially there's no plural forms support at all, and the correct string for initial input is misleading. Not all languages have only two plural forms :)

The JS also has another bug: if there's exactly 1 vote, it prints %s instead of the number (see the screenshot), that's because it replaces %d, but the singular string has %s.

  • Could we use something like Jed for proper plural forms support?
  • If not, could we at least make it so that the correct initial output doesn't get replaced with an incorrect one right away, but only after some other version is selected from the dropdown?
Version 0, edited 4 years ago by SergeyBiryukov (next)

#3 in reply to: ↑ 2 ; follow-up: @coffee2code
4 years ago

Replying to SergeyBiryukov:

The JS also has another bug: if there's exactly 1 vote, it prints %s instead of the number (see the screenshot​), that's because it replaces %d, but the singular string has %s.

This is a result of the translation. From the code snippet I provided above, the original text for a single vote for "works" is: 1 person says it works

The translation (as can be seen for https://ru.wordpress.org/plugins/jetpack/) is
%s сообщение, что работает (ref).

Had the translation used %d instead of %s, the number 1 would have been substituted in. That doesn't solve the plural support issue, but it explains the "bug" of seeing %s.

Could we use something like Jed for proper plural forms support?

Jed would have to be part of a broader discussion for w.org, and possibly more when everything moves to WP. Short of using Jed, are there any suggestions you have for supporting more than 2 plural forms in JS?

This ticket was mentioned in Slack in #meta-i18n by ocean90. View the logs.


4 years ago

#5 @extendwings
4 years ago

This problem is also reported in Japanese forum.
https://ja.forums.wordpress.org/topic/156963

This ticket was mentioned in Slack in #meta by sam. View the logs.


4 years ago

#7 @samuelsidler
3 years ago

  • Resolution set to wontfix
  • Status changed from reopened to closed

I'm wontfixing this ticket because the new directory doesn't / won't have this issue.

#8 in reply to: ↑ 3 @SergeyBiryukov
3 years ago

Replying to coffee2code:

The translation (as can be seen for https://ru.wordpress.org/plugins/jetpack/) is
%s сообщение, что работает (ref).

Had the translation used %d instead of %s, the number 1 would have been substituted in. That doesn't solve the plural support issue, but it explains the "bug" of seeing %s.

Thanks, but why should the translation use %d if the original string uses %s (meta-1322.2.png)? It's an issue with the original string then, not with the translation.

#9 follow-up: @coffee2code
3 years ago

  • Resolution changed from wontfix to fixed

Fixed in [12229-dotorg].

Turns out the issue is the same string appears in two contexts, one as a standalone, non-pluralized string:

__( '1 person says it works.', 'wporg' )

Then again as part of a string pluralization:

_n( '1 person says it works.', '%s people say it works.', $works_num, 'wporg' )

They are actually different strings used in different contexts, but since they aren't otherwise differentiated, only the latter is presented to translators.

The former is used in the JS to set up the singularized string for it to use, and that's what most people will see when then count is 1 (when JS is active, obviously). And the JS only replaces %d with the count, not %s, thus the %s was shown on the front-end. The pluralized version uses %s because in that context the count is passed through bb_number_format_i18n().

I changed the translation of the first instance of the string (as cited above) to be:

_x( '1 person says it works.', 'non-pluralized singular', 'wporg' )
_x( "1 person says it's broken.", 'non-pluralized singular', 'wporg' )

This should cause them to appear as separately translatable strings. In the translation, %d can be used in place of 1.

#10 in reply to: ↑ 9 ; follow-up: @SergeyBiryukov
3 years ago

Replying to coffee2code:

I changed the translation of the first instance of the string (as cited above) to be:

_x( '1 person says it works.', 'non-pluralized singular', 'wporg' )
_x( "1 person says it's broken.", 'non-pluralized singular', 'wporg' )

This should cause them to appear as separately translatable strings. In the translation, %d can be used in place of 1.

Cheers, thank you for the fix!

It seems like the new strings are not yet available for translation though, any idea why?
https://translate.wordpress.org/projects/meta/plugins/ru/default

#11 in reply to: ↑ 10 ; follow-up: @ocean90
3 years ago

Replying to SergeyBiryukov:

It seems like the new strings are not yet available for translation though, any idea why?
https://translate.wordpress.org/projects/meta/plugins/ru/default

The POT generation and import is already disabled for the old directory…

#12 in reply to: ↑ 11 @SergeyBiryukov
3 years ago

Replying to ocean90:

The POT generation and import is already disabled for the old directory…

Could we re-enable it until the new directory is officially launched?

Note: See TracTickets for help on using tickets.