-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
feat: add i18nPaths for selective i18n routing #2131
Conversation
Signed-off-by: Ansh Goyal <[email protected]>
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-2131--asyncapi-website.netlify.app/ |
Signed-off-by: Ansh Goyal <[email protected]>
//cc @magicmatatjahu 🚀 |
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.
Two suggestions, but second one is crucial to add :) Amazing work!
Co-authored-by: Maciej Urbańczyk <[email protected]>
Signed-off-by: Ansh Goyal <[email protected]>
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-2131--asyncapi-website.netlify.app/ |
if ((props.href && i18nPaths[language] && !i18nPaths[language].includes(href)) || href.startsWith("http")) { | ||
return ( | ||
<Link {...props} href={href} passHref> | ||
{children} | ||
</Link> | ||
); | ||
} |
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.
Which usecase is handled in this if
condition? Kindly specify that in comment.
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.
It would handle the cases where a webpage is not yet translated or there is an external website's href
const i18nPaths = { | ||
en: [ | ||
"/tools/cli" | ||
], | ||
de: [ | ||
"/tools/cli" | ||
] | ||
}; |
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.
What is the use of these i18nPaths
?
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.
It would work as a record for the translated links. Since we are using static site generation, we needed a mechanism to predefine the translated webpages which could be used by the i18n LinkComponent
components/navigation/MenuBlocks.js
Outdated
@@ -1,3 +1,4 @@ | |||
import LinkComponent from '../link'; | |||
import Paragraph from '../typography/Paragraph'; | |||
import Label from './Label' | |||
import Link from 'next/link' |
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.
import Link from 'next/link' |
Signed-off-by: Ansh Goyal <[email protected]>
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.
We have these same set of changes in #2184. Let's merge these merges with that PR only and enable all the options in one go 🚀 .
Description
LinkComponent
behaves likenext/link
component and selects the localized paths fromi18nPaths
file to redirect the user according to their localization.Related issue(s)
part of: #2039
How to test changes?
CLI
en/tools/cli
Modelina
/tools/modelina
, since Modelina page is not yet translated.