Skip to content

i18n: localize hardcoded JS strings in check-in and reading log components#12533

Merged
cdrini merged 2 commits into
internetarchive:masterfrom
AhmedxSaid:fix/i18n-js-checkin-reading-log
May 22, 2026
Merged

i18n: localize hardcoded JS strings in check-in and reading log components#12533
cdrini merged 2 commits into
internetarchive:masterfrom
AhmedxSaid:fix/i18n-js-checkin-reading-log

Conversation

@AhmedxSaid

Copy link
Copy Markdown
Contributor

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:

File String
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.html i18n_input() and Carousel.js):

  1. check_in_prompt.html — adds an i18n key to the existing data-config JSON object with the two check-in error strings translated via _().
  2. dropdown_content.html — adds a new <input type="hidden" name="reading-log-i18n-strings"> with the two reading log strings translated via _().
  3. CheckInComponents.js — reads strings from this.config.i18n instead of hardcoded literals.
  4. ReadingLogForms.js — reads the new hidden input on construction and uses the strings; falls back to English if the input is absent.
  5. fr/messages.po — adds French translations for all four new strings.

Test plan

  • Check-in error toasts display in the user's selected language
  • The "saving..." button label displays in the user's selected language
  • The shelf-removal confirmation dialog displays in the user's selected language
  • English fallback still works when reading-log-i18n-strings input is absent
  • French translations render correctly for a fr locale session

🤖 Generated with Claude Code

@mekarpeles mekarpeles requested a review from Copilot May 1, 2026 08:36
@mekarpeles mekarpeles added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 1, 2026
@mekarpeles

Copy link
Copy Markdown
Member

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

  • Proof of testing — The test plan lists what to verify but doesn't include a description of what was tested during development. Please add a brief note on how you verified the changes work (e.g., browser steps taken, locale settings used, observed behavior), or a screenshot of the translated strings in action. See how to attach files.
PR triage checklist (maintainers / Pam)
  • PR description — not empty; explains what the change does and how to verify it
  • References an issue — PR body contains a #NNN reference
    • Linked issue is triaged — has a Priority: * label (not just Needs: Triage)
    • Linked issue is assigned — has at least one assignee
  • Commit history clean — no WIP/fixup/conflict noise; commit messages are meaningful
  • CI passing — no failing check-runs
  • Test cases present — if the change touches substantive logic, test coverage exists or is explained
  • Proof of testing — PR body includes a description of what was tested, a screenshot, or a video

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CheckInComponents and ReadingLogForms to consume injected i18n strings instead of hardcoded literals.
  • Updates i18n catalogs (messages.pot, French messages.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.

@mekarpeles mekarpeles added the State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] label May 2, 2026
@mekarpeles

Copy link
Copy Markdown
Member

Note: blocked on #2607

@github-actions

Copy link
Copy Markdown

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.
For guidance on contributing, please see our Contributing guide.

@github-actions github-actions Bot added Stale Needs: Response Issues which require feedback from lead and removed Stale labels May 10, 2026
@github-actions

Copy link
Copy Markdown

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.
For guidance on contributing, please see our Contributing guide.

@github-actions github-actions Bot added Stale and removed Stale labels May 18, 2026
…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>
@cdrini cdrini force-pushed the fix/i18n-js-checkin-reading-log branch from b38fa71 to 4219001 Compare May 22, 2026 19:15
@github-actions github-actions Bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label May 22, 2026
@cdrini cdrini force-pushed the fix/i18n-js-checkin-reading-log branch from 4219001 to 46c9e8c Compare May 22, 2026 19:21

@cdrini cdrini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small changed, confirmed working locally. Note we'll likely need to rejigger these things as we land on how we want to handle frontend i18n, but I thought it would be better to merge this one in as-is until that happens.

Image

@cdrini cdrini removed State: Blocked Work has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed] Needs: Response Issues which require feedback from lead labels May 22, 2026
@cdrini cdrini merged commit 1e53782 into internetarchive:master May 22, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: JS UI strings in check-in and reading log components are not translatable

4 participants