Opened 8 years ago
Closed 8 years ago
#2035 closed defect (bug) (fixed)
Improve i18n in Ratings_Compat
Reported by: | SergeyBiryukov | Owned by: | 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)
Change History (11)
#3
follow-ups:
↓ 4
↓ 5
@
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
@
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
@
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.
#6
@
8 years ago
Here's the proper plural string in the plugin directory:
https://translate.wordpress.org/projects/meta/plugins/ru/default?filters[original_id]=218585
In 4066: