-
Notifications
You must be signed in to change notification settings - Fork 2k
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: Fix translations on the Use my domain screen #57064
Conversation
Link to Calypso live: https://calypso.live?image=registry.a8c.com/calypso/app:build-17767 |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~71 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~40 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
The Use a domain I own
title on the initial screen and the Suggested setup
title, when you select the Connection your domain
option, still appear untranslated.
topText: __( 'Manage your domain directly on WordPress.com' ), | ||
learnMoreLink: INCOMING_DOMAIN_TRANSFER, | ||
benefits: [ | ||
transferSupported, |
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.
I suppose, these were extracted as separate constants for better readability?
@sdnunca Thanks for the PR. Is this the recommended way to ensure that the correct text is rendered after the translated strings are loaded? It feels redundant to have to list all of the strings twice. Is there a better way we (@Automattic/nomado) could have handled this to avoid this issue? |
@delputnam The redundant strings felt weird to me as well. I've updated the PR to use getters directly when creating the object. @rafaelgalani Thank you so much for your work on this. Apologies for the inconvenience, I was not aware you're already looking into this. @yuliyan Do you see any potential issues with using getters this way? I've double checked to make sure the strings are still extracted correctly and it seems fine. |
@sdnunca, IIRC, initially I got some build errors with the getter syntax and had to switch to |
6fa2478
to
bf1c5f8
Compare
Rebasing on |
@yuliyan Could you please take one last look at it again? I'll merge this PR since some other developments we're doing depend on it. |
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.
@rafaelgalani, I'm getting reference errors when I go to domains/add/use-my-domain/
, likely due to used undefined __
dependency in use-my-domain/index.js.
@@ -304,7 +305,7 @@ function UseMyDomain( { | |||
/* translators: %s - the name of the domain the user will add to their site */ | |||
return sprintf( __( 'Use a domain I own: %s' ), domainName ); | |||
} | |||
}, [ domainName, mode, inputMode ] ); | |||
}, [ domainName, mode, inputMode, __ ] ); |
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.
I think you forgot to call useI18n
hook and as a result __
is not defined in the scope.
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.
That's weird - even weirder that this is not even coming from this PR, anyway, just added it, thanks 😄
/** | ||
* Define properties with translatable strings getters. | ||
*/ | ||
Object.defineProperties( stepsHeading, { |
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.
Object.defineProperties
here could probably be avoided if you use the getter syntax, similar to how it's been done in use-my-domain/utilities/option-info.js
@@ -23,15 +36,15 @@ export const connectADomainStepsDefinition = { | |||
[ stepSlug.SUGGESTED_LOGIN ]: { | |||
mode: modeType.SUGGESTED, | |||
step: stepType.LOG_IN_TO_PROVIDER, | |||
name: __( 'Log in to provider' ), | |||
name: labels[ stepSlug.SUGGESTED_LOGIN ](), |
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.
I don't think this would work - labels[ stepSlug.SUGGESTED_LOGIN ]
will only be called once during the initial property definition, whereas it's expected __
to be always executed when property is accessed.
I missed the Object.defineProperties
loop at the bottom. However, I think this can also be simplified using the getter syntax.
@yuliyan Done! Thanks for your review. Can you please take one last look? 😄 |
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.
Tested again and it seems to be working fine. I couldn't spot any issues, so it LGTM 🚀
@yuliyan Thank you! Merging 🚀 |
Changes proposed in this Pull Request
optionInfo
objects so that__
is called every time they are accessed, to make sure the text is refreshed when translations are loaded.Testing instructions
Related to #325-gh-Automattic/i18n-issues