Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#6368 closed defect (bug) (fixed)

Use proper plural forms in languages with more than two forms

Reported by: netweb Owned by: boonebgorges
Milestone: 2.3 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch
Cc:

Description

Reported via #polyglots on Slack by @ romanbon https://wordpress.slack.com/archives/polyglots/p1428678160001062

Hi, in Ukrainian language Singular form and Plural form for 21, 31... are the same. Sometimes it causes certain problems translating certain strings (problems can be avoided in most cases). Can someone explain me how to handle translation of such strings in the <em>right way</em>?

Via @sergeybiryukov see:

Attachments (4)

plural.jpg (154.0 KB) - added by netweb 5 years ago.
6368.diff (1.1 KB) - added by boonebgorges 5 years ago.
6368.2.diff (18.7 KB) - added by SergeyBiryukov 5 years ago.
6368.bbpress.diff (5.3 KB) - added by SergeyBiryukov 5 years ago.

Download all attachments as: .zip

Change History (19)

@netweb
5 years ago

This ticket was mentioned in Slack in #polyglots by netweb. View the logs.


5 years ago

#2 follow-up: @boonebgorges
5 years ago

The key point seems to be this:

_n() should only be used for the same string with different numbers, not for different strings.

The "single" English string will be used in Slavic languages for 21, 31, etc. So that means our new pagination pattern will look something like 6368.diff. Does that seem right to others? If so, we'll need a patch that covers all such pagination strings, and probably a review of other uses of _n().

@boonebgorges
5 years ago

#3 in reply to: ↑ 2 @SergeyBiryukov
5 years ago

  • Keywords has-patch added; needs-patch removed

Replying to boonebgorges:

Does that seem right to others?

That pattern looks correct, yes. That's what we use in core now.

I've reviewed all other uses of _n() and fixed the affected instances. Also fixed another issue with those strings: _n() show receive an integer (e.g. $blogs_template->total_blog_count) as its third argument, not a string returned by bp_core_number_format() (e.g. $total).

Would appreciate a second pair of eyes to make sure there are no copy/paste errors.

The second patch is for bbPress external. Not sure if it's still used or supported anymore. Should the patch be submitted to bbPress Trac? Attached it here for reference.

#4 @boonebgorges
5 years ago

  • Milestone changed from Awaiting Review to 2.3

Looks good. Thanks, Sergey!

#5 @boonebgorges
5 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 9765:

Improved plural forms for localizable strings.

Strings that are intended for use only in the case of a single item should not
be bundled with strings intended for use with plurals, as this pattern does not
work with languages that use the singular nominal form for numbers other than
one. See https://core.trac.wordpress.org/ticket/28502#comment:23.

This changeset also fixes a few places where a formatted string, rather than a
raw integer, was being passed as the $count value to _n().

Props SergeyBiryukov.
Fixes #6368.

This ticket was mentioned in Slack in #buddypress by netweb. View the logs.


5 years ago

#8 follow-up: @r-a-y
4 years ago

netweb - Thanks for the catch. Not sure if those instances are actually wrong though.

Check out these similar strings in WP trunk:
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/edit-comments.php?marks=189,197,201,204#L183

Could use some feedback from a localization expert!

#9 @boonebgorges
4 years ago

Could use some feedback from a localization expert!

That's not me :) but I think netweb is right. The primary difference between the bp-messages-star examples he lists, and the core examples you point to, is that the former strings have 1 hardcoded into them. The general rule is arising out of https://core.trac.wordpress.org/ticket/28502#comment:23: string pairs in _n() should be exactly the same, except for the plural status of the noun (in English: comment vs comments). If a particular number, like 1, needs its own syntax ("Just a single comment left!"), it should be its own string, outside of _n(). The bp-messages-star examples look like cases where simply swapping 1 with %s would be enough.

#10 @r-a-y
4 years ago

The bp-messages-star examples look like cases where simply swapping 1 with %s would be enough.

Gotcha. Serves me right for replying in the wee hours of the morning!

#11 @r-a-y
4 years ago

In 9881:

Message star: Fix usage of single form when using _n() function.

Props netweb.

See #6368, #6331.

#12 @r-a-y
4 years ago

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

#13 in reply to: ↑ 8 @netweb
4 years ago

Replying to r-a-y:
Could use some feedback from a localization expert!

Replying to boonebgorges:
That's not me :)

Nor I, but Sergey is :)

#14 @SergeyBiryukov
4 years ago

[9881] looks good :)

#15 @DJPaul
3 years ago

  • Component changed from Locale - i18n to I18N
Note: See TracTickets for help on using tickets.