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

i18n syntax additions with nested HTML #9507

Conversation

rebecca-shoptaw
Copy link
Collaborator

@rebecca-shoptaw rebecca-shoptaw commented Jul 1, 2024

Subtask of #9486.

Fix. This PR adds i18n syntax in cases where the text to be translated includes HTML opening/closing tags. See the i18n guide for full syntax info and instructions.

Technical

Separated the PR's by i18n syntax type for ease of review, this one is scoped to cover all the HTML tag-including syntax, i.e. $:_('Please <a href="">click here</a> to learn more').

Also includes removing relevant files from i18n exclude list so as to confirm they now pass the detect-missing-i18n check.

Testing

  1. Find a newly i18n-ed phrase in one of the files that includes nested HTML
  2. Confirm that the syntax includes a :
  3. Confirm that any included opening tags also have a corresponded included closing tag, i.e. $:_('Please <a href="">click here')</a> is incorrect
  4. Check to see that the phrase appears correctly in the messages.pot file
  5. Run the i18n detection script with pre-commit run detect-missing-i18n --all-files
  6. No errors should appear, and the check should pass

Screenshot

Stakeholders

@mekarpeles @cdrini @pidgezero-one

@rebecca-shoptaw rebecca-shoptaw changed the title I18n syntax additions with nested HTML i18n syntax additions with nested HTML Jul 1, 2024
@rebecca-shoptaw rebecca-shoptaw force-pushed the 9486/fix/i18n-syntax-additions-with-inner-html branch from 54a5f0b to c9adfed Compare July 1, 2024 15:29
@mekarpeles mekarpeles self-assigned this Jul 1, 2024
@mekarpeles mekarpeles assigned cdrini and unassigned mekarpeles Jul 8, 2024
@cdrini cdrini assigned scottbarnes and unassigned cdrini Jul 22, 2024
Copy link
Collaborator

@scottbarnes scottbarnes left a comment

Choose a reason for hiding this comment

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

Thanks for this, @rebecca-shoptaw. Just one minor suggestion.

@rebecca-shoptaw rebecca-shoptaw force-pushed the 9486/fix/i18n-syntax-additions-with-inner-html branch from c9adfed to 305858f Compare July 23, 2024 17:02
@scottbarnes scottbarnes force-pushed the 9486/fix/i18n-syntax-additions-with-inner-html branch from c06ff7d to 57eac33 Compare July 26, 2024 04:52
@rebecca-shoptaw
Copy link
Collaborator Author

@scottbarnes It looks like one of my last WARN fixes got lost in the rebase shuffle, $('Inventaire.io: ') in author/view.html should be switched to $_("Inventaire.io: ") since we made the call that we do want to translate brand names (and even if we didn't, we switched to the skip-line comment for exclusions instead of this syntax).

@scottbarnes scottbarnes force-pushed the 9486/fix/i18n-syntax-additions-with-inner-html branch from 11a6282 to 57eac33 Compare July 26, 2024 15:22
rebecca-shoptaw and others added 3 commits July 27, 2024 09:53
The detect_missing_i18n script currently tries to process assignments,
such as `$ details = _('See <a href="%s">details</a>.', change.url())`

After consultation with @cdrini, it was decided to use exclude "$ "
rather than "= _(" to better match the granularity of the existing
exceptions.
This was on linked on /admin/loans and displayed a no longer used loans
menu.
@scottbarnes scottbarnes force-pushed the 9486/fix/i18n-syntax-additions-with-inner-html branch from 57eac33 to 61764b8 Compare July 27, 2024 17:00
@scottbarnes
Copy link
Collaborator

scottbarnes commented Jul 27, 2024

@rebecca-shoptaw, that makes sense about Inventaire.io; I put that back.

For the issue with the i18n missing strings detection, I just ended up adding an exception to the script, and I am requesting a review from @cdrini.

Also, while reviewing this, I noticed some other files may be eligible for deletion, and they may deserve investigation in a separate issue.

It appears that openlibrary/templates/account/email/forgot.html can be deleted, on the theory it is not linked to anywhere, though I only gave this a cursory glance. If it can be deleted, we should decide about deleting the endpoint as well. It is still functional and the template still works.

Another candidate for deletion is openlibrary/admin/templates/admin/index.html, which appears to be an older version of openlibrary/templates/admin/index.html.

Because I made a substantive change to scripts/detect_missing_i18n.py (see 3b085b5), I am requesting a review from @cdrini, as mentioned above.

@scottbarnes scottbarnes requested a review from cdrini July 27, 2024 17:57
@rebecca-shoptaw
Copy link
Collaborator Author

@scottbarnes Sounds good, and thank you for digging into this!!

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm!

@scottbarnes scottbarnes merged commit 4f1cb87 into internetarchive:master Jul 29, 2024
4 checks passed
@cdrini
Copy link
Collaborator

cdrini commented Jul 29, 2024

Oh and something for a future PR: We can delete the python code for admin/loans too! class loans_admin

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.

4 participants