i18n: localize hardcoded JS strings in check-in and reading log components#12533
Conversation
|
Thanks for the contribution, @AhmedxSaid. 🤖 Copilot has been assigned for an initial review. The linked issue (#12531) hasn't been triaged yet — triage happens on Mondays and Fridays. There are currently 85 open non-draft PRs ahead of yours. Possible improvements for this PR
PR triage checklist (maintainers / Pam)
Note This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam 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
Localizes previously hardcoded user-facing strings in the My Books check-in and reading log JavaScript components by passing gettext-translated strings from server-rendered templates into the client.
Changes:
- Injects translated string bundles into templates via
json_encode()(hidden input /data-config). - Updates
CheckInComponentsandReadingLogFormsto consume injected i18n strings instead of hardcoded literals. - Updates i18n catalogs (
messages.pot, Frenchmessages.po) with the new strings.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openlibrary/templates/my_books/dropdown_content.html | Adds a render-once hidden input containing reading-log i18n strings encoded as JSON. |
| openlibrary/templates/my_books/check_ins/check_in_prompt.html | Adds an i18n block to the check-in data-config JSON to supply localized toast messages. |
| openlibrary/plugins/openlibrary/js/my-books/MyBooksDropper/ReadingLogForms.js | Reads and uses injected reading-log i18n strings with English fallbacks. |
| openlibrary/plugins/openlibrary/js/my-books/MyBooksDropper/CheckInComponents.js | Replaces hardcoded toast strings with template-provided localized strings. |
| openlibrary/i18n/messages.pot | Adds the four new msgids for translators. |
| openlibrary/i18n/fr/messages.po | Adds French translations for the four new strings. |
|
Note: blocked on #2607 |
|
Hello! This pull request has been marked as stale because it has been waiting for submitter input for 7 days. If you're still working on this, please add a comment to keep it open. Otherwise, a maintainer will have to determine how to proceed including reassigning or opening the issue for others to work on after communicating with you. |
|
Hello! This pull request has been marked as stale because it has been waiting for submitter input for 7 days. If you're still working on this, please add a comment to keep it open. Otherwise, a maintainer will have to determine how to proceed including reassigning or opening the issue for others to work on after communicating with you. |
…nents Fixes internetarchive#12531 Previously, error toasts and the confirmation dialog in the check-in and reading log dropper were hardcoded English strings in JavaScript, unreachable by the server-side gettext translation system. - Embeds translated strings into `data-config` (check_in_prompt.html) and a new `reading-log-i18n-strings` hidden input (dropdown_content.html) using the existing json_encode() pattern already used by list and carousel components. - CheckInComponents.js reads strings from this.config.i18n. - ReadingLogForms.js reads strings from the new hidden input on init. - Adds French translations for all four new strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
b38fa71 to
4219001
Compare
4219001 to
46c9e8c
Compare

Fixes #12531
Summary
Four user-facing strings in the check-in and reading log JavaScript components were hardcoded in English and invisible to the server-side gettext translation system. This PR makes them translatable using the same
json_encode()hidden-input pattern already used by the list and carousel components.Strings fixed:
CheckInComponents.js'Failed to delete check-in. Please try again in a few moments.'CheckInComponents.js'Failed to submit check-in. Please try again in a few moments.'ReadingLogForms.js'saving...'ReadingLogForms.js'Removing this book from your shelves will delete your check-ins for this work. Continue?'Approach
Follows the existing project pattern (see
dropdown_content.htmli18n_input()andCarousel.js):check_in_prompt.html— adds ani18nkey to the existingdata-configJSON object with the two check-in error strings translated via_().dropdown_content.html— adds a new<input type="hidden" name="reading-log-i18n-strings">with the two reading log strings translated via_().CheckInComponents.js— reads strings fromthis.config.i18ninstead of hardcoded literals.ReadingLogForms.js— reads the new hidden input on construction and uses the strings; falls back to English if the input is absent.fr/messages.po— adds French translations for all four new strings.Test plan
reading-log-i18n-stringsinput is absentfrlocale session🤖 Generated with Claude Code