Making WordPress.org

Opened 8 years ago

Closed 8 years ago

#2035 closed defect (bug) (fixed)

Improve i18n in Ratings_Compat

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: coffee2code's profile coffee2code
Milestone: Priority: normal
Component: Support Forums Keywords: has-patch commit
Cc:

Description

The patch fixes a few i18n issues with the strings introduced in [3961] and [3997] and changed in [4057-4061]:

  • Strings should be complete sentences, not a concatenation of separate phrases. This is not i18n-friendly:
    • __( '...please post %s instead.', 'wporg-forums' )
    • _x( 'here', 'please post here instead', 'wporg-forums' )
    • __( 'You must %s to submit a review.' )
    • _x( 'log in or register', 'verb: You must log in or register to submit a review.' )
  • Add missing translator comments for all placeholders.
  • Add missing number in one _n() instance.
  • $stars_text should use _n().

Attachments (2)

meta-2035.patch (6.6 KB) - added by SergeyBiryukov 8 years ago.
meta-2035.2.patch (1.3 KB) - added by SergeyBiryukov 8 years ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
8 years ago

  • Keywords has-patch commit added

#2 @coffee2code
8 years ago

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

In 4066:

Support Forums: Improve i18n in Ratings_Compat.

Props SergeyBiryukov.
Fixes #2035.

#3 follow-ups: @coffee2code
8 years ago

Thanks again, @SergeyBiryukov!

Your patch went in minus the change of:

$stars_text = sprintf( __( '%d stars', 'wporg-forums' ), $rating );

to

$stars_text = sprintf(
	/* translators: %s: number of stars */
	_n( '%d star', '%d stars', $rating, 'wporg-	$rating
);

In order to maintain the alignment of the per-rating bars, the labels that precede them must be of equal width, thus the text must contain the same amount of characters. There are options for making the text truly translatable according to number, but there are enough considerations to warrant a separate ticket.

Possible approaches:

  • Like amazon.com, use the singular of all the star labels (e.g. 5 star, 4 star).
  • Move the labels to the right of the bars, thus label length does not matter. But given the per-rating counts are already after the bars, the labels would then contain both pieces of information (e.g. 5 stars (106), ... 1 star (32))
  • Set some fixed width for the labels. This could look wonky for languages that have long translations that would wrap, or if we accommodate most of those, then translations (like English) might have excessive space between the label and the bar.
  • Character padding to ensure equal length of labels (inexact unless the font is fixed-width).

I vote for the simplicity of the first option, but I'm sure others have opinions and ideas.

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

  • Resolution fixed deleted
  • Status changed from closed to reopened

Replying to coffee2code:

In order to maintain the alignment of the per-rating bars, the labels that precede them must be of equal width, thus the text must contain the same amount of characters. There are options for making the text truly translatable according to number, but there are enough considerations to warrant a separate ticket.

Thank you for a detailed reply! I think this was previously resolved in #1165 for the (old) plugin directory, no? At least on https://ru.wordpress.org/plugins/wordpress-seo/, the %d star, %d stars string properly supports plural forums and the alignment still looks good.

meta-2035.2.patch fixes a few more issues with one string missed in my previous patch:

  • Remove unnecessary HTML from the translatable string
  • Add missing text domain and translator comment
  • Add number_format_i18n()

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

Replying to coffee2code:

Like amazon.com, use the singular of all the star labels (e.g. 5 star, 4 star).

Neither this nor the current string works for languages with more than 2 plural forms, e.g. in Russian and other Slavic languages there are three different forms: 1 звезда, 2—4 звезды, 5 звёзд. Neither one of them would work for all 1 to 5 numbers.

So I really hope the solution from #1165 could be applied here as well.

#7 @coffee2code
8 years ago

In 4228:

Support Forums: Another i18n improvement in Ratings_Compat.

  • Move HTML out from translatable string
  • Add missing text domain and translator comment
  • Add use of number_format_i18n()

Props SergeyBiryukov.
See #2035.

#8 @coffee2code
8 years ago

In 4229:

Support Forums: Use %s instead of %d as placeholder since markup and a potentially commaified value is being inserted rather than a simple number.

See #2035, r4228.

#9 @coffee2code
8 years ago

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

In 4230:

Support Forums: Allow for pluralization of the string for the number of stars in the ratings widget.

Syncs the ratings widget with changes made to the old plugin directory a year ago to handle just this very thing.

Props SergeyBiryukov.
Fixes #2035.

Note: See TracTickets for help on using tickets.