Fix #7388: use ungettext() for rating pluralization in star rating macros#12971
Conversation
|
Thank you @Entropy-rgb for this contribution — and welcome to Open Library! 🎉 🤖 Copilot has been assigned for an initial review. @cdrini is assigned to this PR and currently has:
Possible improvements for this PR
PR triage checklist (maintainers / Richy)
Note This comment was automatically generated by Richy, via PAM, Open Library's Project AI Manager, on behalf of @mekarpeles. Richy is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting. |
There was a problem hiding this comment.
Pull request overview
Updates star rating macros to use locale-aware pluralization for the “rating/ratings” label by switching to ungettext(...), and refreshes the translation template accordingly.
Changes:
- Replaced manual singular/plural branching with
ungettext('rating', 'ratings', ratings_count)in star rating macros. - Updated
messages.potto represent “rating” as a pluralizable message (msgid/msgid_plural).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openlibrary/macros/StarRatingsComponent.html | Uses ungettext for the ratings label to support locale plural rules. |
| openlibrary/macros/StarRatingsByline.html | Uses ungettext for the ratings label (but currently needs a None-safe count). |
| openlibrary/i18n/messages.pot | Converts “rating/ratings” into a plural-form entry in the POT. |
cdrini
left a comment
There was a problem hiding this comment.
Nice great start @Entropy-rgb ! Two changes for you.
Also could you take a look at the issue in trending.html listed here? #7388 (comment) . Is this still an issue?
|
Checked trending.html — it doesn't contain any rating pluralization logic, so no changes needed there. |
4bb8ac8 to
4cc8c26
Compare
cdrini
left a comment
There was a problem hiding this comment.
Looking good! One small fix, and then will give this a test later today.
2783c20 to
d44adf1
Compare
… star rating macros
Replace manual singular/plural selection with `ungettext('rating', 'ratings', ratings_count)` in
`openlibrary/macros/StarRatingsByline.html` and `openlibrary/macros/StarRatingsComponent.html`
to support locale-aware plural forms.
…s and trending
- Add format_decimal() helper using babel for locale-aware decimal formatting
- Replace hardcoded "%.1f" and "{:,}".format() with format_decimal()/commify()
- Use ungettext() for plural-sensitive strings in trending.html
Co-Authored-By: Drini Cami <[email protected]>
d44adf1 to
84a59ab
Compare


Replace manual singular/plural selection with
ungettext('rating', 'ratings', ratings_count)inopenlibrary/macros/StarRatingsByline.htmlandopenlibrary/macros/StarRatingsComponent.htmlto support locale-aware plural forms.Closes #7388
fix
Technical
Replaced manual singular/plural branching with ungettext() so that plural forms are handled correctly across all locales, not just English. The count is now embedded inside the ungettext string in StarRatingsComponent.html as required by the i18n guide. Removed unused ratings_label variable from StarRatingsByline.html.
Testing
Screenshot
Stakeholders
@cdrini