-
Notifications
You must be signed in to change notification settings - Fork 153
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
Refactor newsletter petition localization #12249
base: main
Are you sure you want to change the base?
Refactor newsletter petition localization #12249
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @robdivincenzo , can’t wait to see this hack go away :)
Just flagged a few strings that were sneakily using aliases with a different copy than the actual string (mostly due to HTML tags).
This being said, I can confirm the content gets properly extracted in .po files!
source/js/components/newsletter-signup/organisms/with-submission-logic.jsx
Outdated
Show resolved
Hide resolved
source/js/components/newsletter-signup/organisms/with-submission-logic.jsx
Outdated
Show resolved
Hide resolved
source/js/components/newsletter-signup/organisms/default-layout-signup.jsx
Outdated
Show resolved
Hide resolved
Great catch @TheoChevalier ! I've updated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the documentation linked is for templates only, here we can only use what is in the JavaScript section and it works slightly differently: https://docs.djangoproject.com/en/5.0/topics/i18n/translation/#internationalization-in-javascript-code |
Thanks Theo, I see it now 😅. Since that value is passed back to React, React is going to escape it by default. The html needs explicitly defined. How would you feel with the translated text fragmented out? Something like:
We could use pgettext to export a comment you'd think necessary for an accurate translation of the fragments. I made it "Fragment of: [alias]" so it could be identified as a fragment of whatever alias. We could also put the whole html string there if you wanted, but that might be too verbose. |
Thanks @robdivincenzo , let’s please use the whole HTML then, because it won’t work in some languages as translators often need to move the linked part (maybe not true for our current set of languages, but will surely be the case in other strings or when we support new languages) |
6552c4d
to
ca930b0
Compare
Hey @TheoChevalier, knowing that translators might need to move the link around, I've tweaked the idea slightly. The translation now has 3 pieces for |
source/js/components/newsletter-signup/organisms/with-submission-logic.jsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, strings with back-ticks are not extracted anymore
… of github.com:MozillaFoundation/foundation.mozilla.org into TP1-24-12049-refactor-newsletter-petition-localization
Thanks @TheoChevalier, please try once more. The docs suggested it was available in our version of gettext, but you're right that it doesn't export. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR refactors the localization methods for the newsletter and petition components. Now that
gettext
is exporting localization strings properly viainv makemessages
, we're revisiting these components to replace the hardcodedgetText
method.This first PR is a confirmation that everything is exporting properly for Pontoon translation. Further work is needed to remove
locale-strings.jsx
andgetText
method across the codebase, and will be completed via follow-up issues.Link to sample test page:
Related PRs/issues: #11910 #12100 #12049
To Test
inv makemessages
┆Issue is synchronized with this Jira Story