website
website copied to clipboard
fix: make i18n work for the newsletter page
Description
- Updated proper internationalization for the newsletter page by following the guidelines given in documentation.
- /en/newsletter and /de/newsletter works well, /newsletter page defaults to defined
entext
/en/newsletter and /newsletter:
/de/newsletter:
Implementation details
- The previous newsletter page used i18n but didn't have the parent element to initialize them.
- Then I have copied the newsletter page into
pages/[lang]folder, edited it by adding scripts into it, to properly use the language selected by user and hence can see the corresponding text. - Now the user can go to i18n page. If /newsletter is hit, server detects the language and takes them to the appropriate page automatically, due to the
Redirects()used in thepages/newsletter.tsx. - I have edited the
components/NewsLetterSubscribe.tsxto adapt to both types of pages by using thereadyvariable returned from useTranslation. - As only newsletterCTA is being used in that component from the locale file, I have used { keyprefix: 'newsletterCTA' } in the useTranslation so that we can access the values directly.
Related issue Fixes #3236 The issue of labels in buttons and placeholder existed because, the i18n implementation was not working then. As this PR properly implements i18n, that issue of buttons too got eliminated!
Summary by CodeRabbit
Summary by CodeRabbit
-
New Features
- Introduced a new landing page for newsletter subscriptions, enhancing user accessibility.
- Added an optional error message feature in the newsletter subscription component for improved user feedback.
-
Improvements
- Enhanced internationalization support for the newsletter subscription component, ensuring translations are displayed correctly.
- Added new routing capabilities for the newsletter in multiple languages.
-
Bug Fixes
- Implemented redirection logic in the newsletter index page to streamline user navigation.
Walkthrough
The pull request introduces several changes across multiple files to enhance the newsletter subscription feature. The NewsletterSubscribe component now supports a custom error message through a new optional property, errorSubtitle, and improves translation readiness. A new landing page component, NewsletterIndexPage, is added to facilitate the subscription interface, alongside updates to routing for internationalization. Additionally, a redirection mechanism is implemented in the existing newsletter page to modify user navigation.
Changes
| File | Change Summary |
|---|---|
| components/NewsletterSubscribe.tsx | Updated import for useTranslation, added errorSubtitle to props, enhanced translation logic. |
| pages/[lang]/newsletter.tsx | Introduced NewsletterIndexPage component, added getStaticProps and getStaticPaths. |
| utils/i18n.ts | Added /newsletter route to i18nPaths for English and German. |
| pages/newsletter.tsx | Added Redirect function to control flow in NewsletterIndexPage. |
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Correct button labels in the newsletter page (#3236) | ❌ | The changes do not address the button label issue. |
Suggested labels
ready-to-merge, bounty
Suggested reviewers
- derberg
- magicmatatjahu
- sambhavgupta0705
- akshatnema
- asyncapi-bot-eve
- Mayaleeeee
Poem
In the meadow where bunnies play,
A newsletter blooms bright as day.
With labels now clear, and messages right,
Our subscriptions take off, a joyful flight! 🐇✨
Hops of delight, with translations anew,
Come join us, dear friends, there's room for you!
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL
📥 Commits
Reviewing files that changed from the base of the PR and between 82edcd95845646cec4618a9df9ca8b162b3accd5 and 5a3a83547f09b61c3fac26789696fa33c27a89c0.
📒 Files selected for processing (4)
components/NewsletterSubscribe.tsx(7 hunks)pages/[lang]/newsletter.tsx(1 hunks)pages/newsletter.tsx(1 hunks)utils/i18n.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- components/NewsletterSubscribe.tsx
- pages/[lang]/newsletter.tsx
- pages/newsletter.tsx
- utils/i18n.ts
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Deploy Preview for asyncapi-website ready!
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | 4654485646360ad91606f51910f4ae5305c53ea8 |
| Latest deploy log | https://app.netlify.com/sites/asyncapi-website/deploys/674abee5bd1d950008e42c27 |
| Deploy Preview | https://deploy-preview-3308--asyncapi-website.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
⚡️ Lighthouse report for the changes in this PR:
| Category | Score |
|---|---|
| 🔴 Performance | 35 |
| 🟢 Accessibility | 98 |
| 🟢 Best practices | 92 |
| 🟢 SEO | 100 |
| 🔴 PWA | 33 |
Lighthouse ran on https://deploy-preview-3308--asyncapi-website.netlify.app/
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 67.77%. Comparing base (
f726a6d) to head (4654485). Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #3308 +/- ##
=======================================
Coverage 67.77% 67.77%
=======================================
Files 21 21
Lines 664 664
=======================================
Hits 450 450
Misses 214 214
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@Varun-Kolanu @akshatnema is there anything pending on this PR? It would be nice to have the labels showing correctly 🙏
Thank you so much!
@Varun-Kolanu @akshatnema is there anything pending on this PR? It would be nice to have the labels showing correctly 🙏
Thank you so much!
The work is done imo and this PR fixes the issue. I'm just waiting for a maintainer to review and merge.
Hey @Varun-Kolanu @akshatnema , on the community/events page the calender buttons need to fixed for i18n issue.
Rest everything seems fine to me.
Hey @SahilDahekar, actually there are other pages too which need to have i18n enabled. As the issue revolved around making newsletter page, I just made the changes for that page. I think this might be opened as a new issue or if @akshatnema suggests to make all the pages work for i18n, I may add changes for those pages too
/rtm