-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[i18n] Localize string in Instruction.js
#6984
Conversation
✔️ Deploy Preview for web-dev-staging ready! 🔨 Explore the source changes: bd50355 🔍 Inspect the deploy log: https://app.netlify.com/sites/web-dev-staging/deploys/61af91581a82e500077a3642 😎 Browse the preview: https://deploy-preview-6984--web-dev-staging.netlify.app |
@@ -25,7 +27,7 @@ const capitalize = require('../../_filters/capitalize'); | |||
* @param {string} listStyle The list style to use. Defaults to 'ul'. | |||
* @return {string} A list of instructions. | |||
*/ | |||
module.exports = (type, listStyle = 'ul') => { | |||
module.exports = (type, listStyle = 'ul', locale = defaultLocale) => { |
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.
Let's avoid changing the way this function is called (eg by adding new parameters). You can use getLocaleFromPath to get locale instead, as shown here: https://github.com/GoogleChrome/web.dev/blob/main/src/site/_includes/components/Aside.js#L35
Please note that for this to work you need to change the notation of the component definition from arrow function for "function() {...}"
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.
Oh!!! That's the trick. Thanks. Will update it now.
Fantastic, thanks a lot @chybie ! I left one comment everything else looks great. |
Updated. PTAL. |
@devnook please help to approve the Percy web changes as well |
Fixes #6982
Add an optional
locale
param in theInstruction
shortcode. Can use that like below in any article, especially translated one.Preferably able to access to
@this {EleventyPage}
object like thecomponents/Aside.js
, then we can eliminate this additionallocale
param. However, I couldn't get that work.