Skip to content

Conversation

@HeheAnanya
Copy link

@HeheAnanya HeheAnanya commented Mar 8, 2025

Before:
image

image

After:

image image

Description

  • Fixed translation of navbar, and footer.

Related issue(s)
Fixes #3716

Summary by CodeRabbit

  • New Features
    • UI elements such as the footer and navigation items now support dynamic, localized text, providing an improved multilingual experience.
    • New localized content for English and German has been added, enhancing accessibility.
    • Multiple pages benefit from enhanced pre-rendering, which improves load times and overall performance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

Walkthrough

This pull request introduces internationalization support and static property generation improvements. The Footer, NavBar, and NavItem components now use a unified translation utility instead of hardcoded strings. Additionally, several pages across the site have been updated to include or modify a static generation function (getStaticProps) using a centralized makeStaticProps utility, with the translation keys expanded to include a new "component" key. New locale JSON files have also been added for both English and German.

Changes

File(s) Change Summary
components/footer/Footer.tsx Integrated useTranslation from @/utils/i18n; replaced hardcoded text with translation keys; adjusted CSS classes.
components/navigation/NavBar.tsx, components/navigation/NavItem.tsx Updated import paths to use the unified i18n utility; dynamic translation added for navigation text.
next-i18next.config.cjs Removed an extraneous comment; no impact on functionality.
pages/[lang]/index.tsx Updated getStaticProps to include the new 'component' key in the static props configuration.
pages/blog/index.tsx, pages/casestudies/index.tsx, pages/community/*, pages/roadmap.tsx, pages/tools/* Added or updated getStaticProps using makeStaticProps with keys ['landing-page', 'footer', 'common', 'component'] for improved static generation.
public/locales/en/component.json, public/locales/de/component.json New localization JSON files added for English and German, containing translations for footer and navigation elements.

Sequence Diagram(s)

sequenceDiagram
    participant C as Component
    participant T as useTranslation Hook
    participant I as i18n Utility
    C->>T: Initialize translation
    T->>I: Request translation keys
    I-->>T: Return localized strings
    T-->>C: Provide translations for rendering
Loading
sequenceDiagram
    participant U as User Request
    participant P as Page Component
    participant G as getStaticProps
    participant M as makeStaticProps Utility
    U->>P: Request page load
    P->>G: Invoke getStaticProps (with keys array)
    G->>M: Call makeStaticProps([...])
    M-->>G: Return static props data
    G-->>P: Provide props for page rendering
Loading

Possibly related PRs

Suggested labels

ready-to-merge, gsoc

Suggested reviewers

  • derberg
  • akshatnema
  • magicmatatjahu
  • anshgoyalevil
  • Mayaleeeee
  • devilkiller-ag
  • sambhavgupta0705
  • asyncapi-bot-eve

Poem

I’m a rabbit, hopping in code delight,
Translating strings from morning till night.
With keys and props, our pages gleam,
Static data flows like a laser beam.
In the garden of code, I joyfully roam,
🐰 Cheers to a site that feels like home!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@netlify
Copy link

netlify bot commented Mar 8, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 37e6fe9
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67cc7ae3eac2b000081465d1
😎 Deploy Preview https://deploy-preview-3847--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
public/locales/de/component.json (1)

1-39: Good addition of German translations for components.

The file provides comprehensive translations for navbar and footer elements, directly addressing the translation issues mentioned in the PR objectives.

A few suggestions for improving the translations:

  • Line 10: "Um" seems too short for "About", consider using "Über uns"
  • Line 17: "Schicken Sie uns eine E-Mail" is correct but "Kontaktieren Sie uns" might be more common
  • Line 27: The emoji in the love expression will render correctly, good job keeping this consistent with other locales
pages/community/ambassadors/index.tsx (1)

156-163: Consider translating social media link texts.

These social media link texts ("Twitter ↗", "Github ↗", "Linkedin ↗") are currently hardcoded and won't be translated automatically.

-                    Twitter ↗
+                    {t('social.twitter')} ↗

Similarly for Github and Linkedin links. This would require adding the appropriate translation hook:

+import { useTranslation } from '@/utils/i18n';

export default function Index() {
+  const { t } = useTranslation();
  const image = '/img/social/community-ambassadors.webp';
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2561b52 and 37e6fe9.

📒 Files selected for processing (21)
  • components/footer/Footer.tsx (3 hunks)
  • components/navigation/NavBar.tsx (1 hunks)
  • components/navigation/NavItem.tsx (4 hunks)
  • next-i18next.config.cjs (1 hunks)
  • pages/[lang]/index.tsx (2 hunks)
  • pages/blog/index.tsx (1 hunks)
  • pages/casestudies/index.tsx (2 hunks)
  • pages/community/ambassadors/index.tsx (2 hunks)
  • pages/community/dashboard.tsx (1 hunks)
  • pages/community/events/index.tsx (1 hunks)
  • pages/community/index.tsx (2 hunks)
  • pages/community/newsroom.tsx (1 hunks)
  • pages/community/tsc.tsx (2 hunks)
  • pages/roadmap.tsx (2 hunks)
  • pages/tools/generator.tsx (2 hunks)
  • pages/tools/github-actions.tsx (1 hunks)
  • pages/tools/index.tsx (1 hunks)
  • pages/tools/modelina.tsx (2 hunks)
  • pages/tools/parsers.tsx (1 hunks)
  • public/locales/de/component.json (1 hunks)
  • public/locales/en/component.json (1 hunks)
🔇 Additional comments (35)
next-i18next.config.cjs (1)

11-11: LGTM - Removed unnecessary comment.

The removal of the comment doesn't affect functionality while making the code cleaner.

pages/tools/parsers.tsx (1)

4-4: Good addition of internationalization support.

Adding getStaticProps with the appropriate namespaces will enable proper translation of this page, aligning with the PR objective of fixing translation issues.

Note that you're now correctly including the 'component' namespace which contains the navbar and footer translations.

Also applies to: 12-14

pages/community/ambassadors/index.tsx (1)

7-7: Good addition of internationalization support.

Adding getStaticProps with the appropriate namespaces enables proper translation of the ambassadors page, consistent with the changes made to other pages.

The inclusion of the 'component' namespace ensures that navbar and footer elements will be properly translated on this page as well.

Also applies to: 16-18

pages/community/index.tsx (2)

6-6: Import added for internationalization support.

This import of makeStaticProps is correctly added to enable translation support for this page.


24-26: Internationalization setup added for the Community page.

The getStaticProps function is correctly implemented using makeStaticProps with the appropriate translation namespaces. This enables proper translation of the page content, including the newly added component namespace.

pages/community/newsroom.tsx (2)

3-4: Import added for internationalization support.

This import of makeStaticProps is correctly added to enable translation support for the Newsroom page.


9-12: Internationalization setup added for the Newsroom page.

The getStaticProps function is properly implemented and exported, following the same pattern used throughout the application. This ensures consistent internationalization across all pages.

pages/casestudies/index.tsx (2)

6-6: Import added for internationalization support.

This import of makeStaticProps is correctly added to enable translation support for the Case Studies page.


27-30: Internationalization setup added for the Case Studies page.

The getStaticProps function is properly implemented and exported, with the correct namespaces required for translation, including the new 'component' namespace.

public/locales/en/component.json (1)

1-40: New translation file added for component-specific strings.

This translation file contains well-structured keys for footer and navbar elements, enabling proper internationalization of these components. The organization is clean, with logical grouping of related UI elements.

The footer section contains all necessary elements including taglines, section labels, and social media links. The navbar section includes all main navigation items. This structure will allow for easy translation to other languages.

pages/tools/github-actions.tsx (2)

4-4: Good addition of the i18n utility import.

The addition of makeStaticProps import from '@/utils/getStatic' enables internationalization support for this page.


12-14: Well implemented static props for internationalization.

The implementation of getStaticProps using makeStaticProps with translation namespaces ('landing-page', 'footer', 'common', 'component') ensures that the page will properly support translations, which aligns with the PR's goal of fixing translation issues.

pages/roadmap.tsx (2)

7-7: Good addition of the i18n utility import.

The addition of makeStaticProps import from '@/utils/getStatic' enables internationalization support for this page.


17-19: Well implemented static props for internationalization.

The implementation of getStaticProps using makeStaticProps with translation namespaces ('landing-page', 'footer', 'common', 'component') ensures that the page will properly support translations, which aligns with the PR's goal of fixing translation issues.

components/navigation/NavBar.tsx (1)

6-6: Good centralization of i18n utilities.

Replacing the direct import from 'next-i18next' with a centralized import from '@/utils/i18n' is a good practice for maintaining consistent internationalization across the application. This change is crucial for fixing the navbar translation issues mentioned in the PR objectives.

pages/tools/index.tsx (2)

5-5: Good addition of the i18n utility import.

The addition of makeStaticProps import from '@/utils/getStatic' enables internationalization support for this page.


13-15: Well implemented static props for internationalization.

The implementation of getStaticProps using makeStaticProps with translation namespaces ('landing-page', 'footer', 'common', 'component') ensures that the page will properly support translations, which aligns with the PR's goal of fixing translation issues.

pages/community/dashboard.tsx (2)

3-3: Properly adds internationalization support

The import of makeStaticProps is appropriate for enabling translations on this page.


11-13: Correctly configures static properties for i18n

The implementation correctly adds the necessary translation namespaces (landing-page, footer, common, and component) that will enable proper translation of the page components as mentioned in the PR objectives.

pages/tools/modelina.tsx (2)

4-4: Good addition of i18n support

The import of makeStaticProps is consistent with the internationalization approach used throughout the project.


14-16: Correctly implements translation configuration

The implementation follows the project's pattern for enabling translations, using consistent namespaces across pages.

pages/community/tsc.tsx (2)

4-4: Appropriately adds i18n support

The import statement is correctly added to support translations for this page.


14-16: Consistent translation namespace implementation

The static props configuration uses the same namespaces as other pages, ensuring consistent translation behavior across the site, which aligns with the PR objectives to fix translation issues.

pages/tools/generator.tsx (2)

5-5: Properly integrates i18n support

The import statement correctly adds makeStaticProps to enable translation capabilities.


17-19: Implements translation support correctly

The export of getStaticProps with the consistent set of namespaces will enable proper translation of the page elements, addressing the translation issues mentioned in the PR objectives.

components/navigation/NavItem.tsx (3)

5-5: Good addition of internationalization support.

Adding the useTranslation hook is the first step to implement i18n for the navigation items.


38-38: Correct implementation of the translation hook.

The translation hook is properly initialized with the 'component' namespace which will be used for all navigation-related translations.


50-50: Consistent implementation of translations for all text instances.

You've consistently replaced all hardcoded text instances with translation functions using the same pattern t('navbar.${text}'). This ensures that all navigation items can be properly translated.

Also applies to: 72-72, 80-80

pages/blog/index.tsx (1)

16-20: Good addition of internationalization support for static props.

Adding 'component' to the static props namespaces ensures that navbar and footer translations will be available on this page.

pages/community/events/index.tsx (1)

18-18: Consistent update to include component namespace.

This change ensures that the events page will have access to the component translations, matching the pattern used in other pages.

components/footer/Footer.tsx (3)

6-6: Good implementation of internationalization for the footer.

Adding the useTranslation hook from i18n utils and initializing it with the 'component' namespace is consistent with the approach used in the NavItem component.

Also applies to: 16-16


32-32: Comprehensive implementation of translations for all text elements.

All static text elements in the footer have been properly replaced with translation function calls, using a consistent naming pattern that follows good i18n practices. This includes section headings and the tagline.

Also applies to: 42-42, 50-50, 61-61, 67-67, 77-77


31-31: Layout adjustments for internationalization.

The CSS adjustments (width, padding, margin) are appropriate to accommodate text of different lengths in various languages. This is good practice when implementing internationalization.

Also applies to: 39-39, 58-58, 74-74

pages/[lang]/index.tsx (2)

5-5: Good centralization of translation utilities!

Moving from next-i18next to a custom utility at @/utils/i18n helps maintain consistent translation handling across components. This change aligns with fixing the translation issues mentioned in the PR.


32-32: Translation namespace expansion is perfect for fixing component translations

Adding 'component' to the makeStaticProps function arguments ensures that component-specific translations (like those for navbar and footer) are properly loaded during static generation. This directly addresses the translation issues in the navbar and footer mentioned in the PR objectives.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Mar 8, 2025

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 The subject "Translation of the page is not working as expected." found in the pull request title "fix: Translation of the page is not working as expected." should start with a lowercase character.

@codecov
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2561b52) to head (37e6fe9).
Report is 64 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3847   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines          667       667           
  Branches       113       113           
=========================================
  Hits           667       667           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vishvamsinh28
Copy link
Contributor

@HeheAnanya There's a lint error—lowercase the title to fix it. I also noticed some design issues, such as the spacing between the AsyncAPI logo and the dropdown next to it. Additionally, 'Blog' and 'Roadmap' are not translated. The 'Star on GitHub' it looks weird in the translated version—can you fix these minor design issues as well?

@sambhavgupta0705
Copy link
Member

closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Translation of the page is not working as expected.

4 participants