-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add i18nPaths for selective i18n routing #2131
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
Conversation
Signed-off-by: Ansh Goyal <anshgoyal1704@gmail.com>
✅ 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 <anshgoyal1704@gmail.com>
|
//cc @magicmatatjahu 🚀 |
magicmatatjahu
left a 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.
Two suggestions, but second one is crucial to add :) Amazing work!
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Signed-off-by: Ansh Goyal <anshgoyal1704@gmail.com>
|
⚡️ 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
| 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 <anshgoyal1704@gmail.com>
akshatnema
left a 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.
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
LinkComponentbehaves likenext/linkcomponent and selects the localized paths fromi18nPathsfile to redirect the user according to their localization.Related issue(s)
part of: #2039
How to test changes?
CLIen/tools/cliModelina/tools/modelina, since Modelina page is not yet translated.