Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix untranslated error messages in add.html and web.html. #8848

Closed
rebecca-shoptaw opened this issue Feb 27, 2024 · 2 comments · Fixed by #8874
Closed

Fix untranslated error messages in add.html and web.html. #8848

rebecca-shoptaw opened this issue Feb 27, 2024 · 2 comments · Fixed by #8874
Assignees
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]

Comments

@rebecca-shoptaw
Copy link
Collaborator

Problem

While working on another issue, I noticed that a few strings in the cover and link adding forms are not getting translated because they are written in the JavaScript rather than the HTML files, so get ignored for internationalization: i.e. $('#link-errors').html('Please provide a label.'); in edit.js

Evidence / Screenshot

Screenshot 2024-02-27 at 2 59 08 PM Screenshot 2024-02-27 at 2 54 39 PM

Reproducing the bug

  1. Change site language to any non-English language
  2. Go to a work page
  3. Try to enter a link with no label (below the excerpts)
  • Expected behavior: "Please provide a label" appears in the language you've selected for the site.
  • Actual behavior: "Please provide a label" appears in English.

Note: You can follow the same process with trying to submit a new cover image without entering a link or an image file.

Context

  • OS (Windows, Mac, etc): Mac
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): prod

⚠️ Experienced contributors only

Proposal & constraints

Very simple! The clearest way to fix the problem would be to replicate the approach @cdrini suggested for #8754 - transfer the relevant error messages into the HTML as a data attribute, and then access the data attribute in the JavaScript as needed.

This can also be bundled with a quick fix to make the "URL" and "Add Link" text correctly formatted for internationalization directly in the HTML.

Related files

openlibrary/plugins/openlibrary/js/edit.js
openlibrary/templates/books/edit/web.html

openlibrary/plugins/openlibrary/js/covers.js
openlibrary/templates/books/add.html

Stakeholders

@rebecca-shoptaw rebecca-shoptaw added Needs: Lead Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Type: Bug Something isn't working. [managed] labels Feb 27, 2024
@rebecca-shoptaw
Copy link
Collaborator Author

This is very similar to a previous PR I did, and should be nice and straightforward, so I'd love to work on it!

@jimchamp jimchamp added Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Feb 27, 2024
@jimchamp
Copy link
Collaborator

Go for it! Add the translated strings as an object in a data-i18n attribute (there are many examples of this in the codebase). Let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @jimchamp Issues overseen by Jim (Front-end Lead, BookNotes) [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants