Skip to content
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

fix: fix footer language not changing when language is changed #3722

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Recxsmacx
Copy link

@Recxsmacx Recxsmacx commented Feb 22, 2025

Fixes #3720

Add language support to the footer section to address the issue of the footer text not changing when the language is switched.

  • Footer Component (components/footer/Footer.tsx)

    • Import useTranslation hook from next-i18next.
    • Use useTranslation hook to get the t function.
    • Replace hardcoded text with t function calls for translation.
    • Add currentLanguage prop to the Footer component.
    • Use currentLanguage prop to determine the language for translations.
  • Next-i18next Configuration (next-i18next.config.js)

    • Add footer to the namespaces array.
  • App Component (pages/_app.tsx)

    • Pass the current language as a prop to the Footer component.
  • Translation Files

    • Add English translations for the footer section in public/locales/en/footer.json.
    • Add German translations for the footer section in public/locales/de/footer.json.

Summary by CodeRabbit

  • New Features

    • Enhanced multilingual support with dynamic translations for footer content, now available in English and German.
  • Refactor

    • Improved footer layout and spacing for a cleaner, more responsive user interface.
  • Chore

    • Updated translation configuration to streamline localization across the application.

Fixes asyncapi#3720

Add language support to the footer section to address the issue of the footer text not changing when the language is switched.

* **Footer Component (`components/footer/Footer.tsx`)**
  - Import `useTranslation` hook from `next-i18next`.
  - Use `useTranslation` hook to get the `t` function.
  - Replace hardcoded text with `t` function calls for translation.
  - Add `currentLanguage` prop to the `Footer` component.
  - Use `currentLanguage` prop to determine the language for translations.

* **Next-i18next Configuration (`next-i18next.config.js`)**
  - Add `footer` to the `namespaces` array.

* **App Component (`pages/_app.tsx`)**
  - Pass the current language as a prop to the `Footer` component.

* **Translation Files**
  - Add English translations for the footer section in `public/locales/en/footer.json`.
  - Add German translations for the footer section in `public/locales/de/footer.json`.
Copy link

netlify bot commented Feb 22, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1d21455
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67b9f30d321dd00008575fe0
😎 Deploy Preview https://deploy-preview-3722--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.

@Recxsmacx Recxsmacx changed the title BUG : fix footer language not changing when language is changed fix: fix footer language not changing when language is changed Feb 22, 2025
@Recxsmacx
Copy link
Author

@anshgoyalevil @sambhavgupta0705 @devilkiller-ag @derberg @Mayaleeeee please review this one!

@Recxsmacx
Copy link
Author

image

this is the final output

Copy link
Member

@devilkiller-ag devilkiller-ag left a comment

Choose a reason for hiding this comment

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

Hi @Recxsmacx, Can you check why the deploy preview is failing and fix it?

Copy link
Contributor

coderabbitai bot commented Feb 22, 2025

Walkthrough

The pull request integrates internationalization into the Footer component. The Footer now accepts a new required prop (currentLanguage) defined by a freshly added interface. It uses the useTranslation hook from next-i18next for dynamic text rendering. Layout adjustments refine spacing and structure for sections such as initiative, news, and social media. The i18n configuration is updated to include a new 'footer' namespace, and new translation JSON files for English and German have been added. Additionally, the locale from the router is extracted and passed to Footer via the _app.tsx component.

Changes

File(s) Change Summary
components/footer/Footer.tsx Updated Footer component: added FooterProps interface with currentLanguage prop, integrated useTranslation, restructured layout, and replaced hardcoded texts with translation keys.
pages/_app.tsx Extracted locale from the router and passed it as the currentLanguage prop to the Footer component.
next-i18next.config.js Added a new 'footer' namespace to the configuration to support footer-specific internationalization.
public/locales/{en,de}/footer.json Introduced new translation files for English and German, containing localized strings for the footer section.

Sequence Diagram(s)

sequenceDiagram
  participant Browser as Browser
  participant Router as Router
  participant App as _app.tsx
  participant Footer as Footer Component
  participant i18n as next-i18next

  Browser->>Router: Request page with locale
  Router->>App: Provide locale information
  App->>Footer: Pass `currentLanguage` prop (locale)
  Footer->>i18n: Call useTranslation (with footer namespace)
  i18n-->>Footer: Return localized strings
  Footer-->>Browser: Render translated footer content
Loading

Possibly related PRs

Suggested labels

ready-to-merge, autoupdate

Suggested reviewers

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

Poem

I'm a bunny with a joyful hop,
Skipping through code without a stop.
Footer sings in every tongue aloud,
With translations making it proud.
Carrots and keys, in unity we bound! 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ 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. (Beta)
  • @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.

@Recxsmacx
Copy link
Author

@devilkiller-ag its solved now !

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: 2

🧹 Nitpick comments (1)
components/footer/Footer.tsx (1)

39-41: Fix Tailwind CSS class order.

The class order in several elements needs to be fixed according to the Tailwind CSS convention.

-<Heading typeStyle={HeadingTypeStyle.smSemibold} className='text-white mb-2'>
+<Heading typeStyle={HeadingTypeStyle.smSemibold} className='mb-2 text-white'>

Also applies to: 57-59, 71-73, 90-92

🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 39-39: Invalid Tailwind CSS classnames order tailwindcss/classnames-order

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 881a4c7 and 1d21455.

📒 Files selected for processing (5)
  • components/footer/Footer.tsx (2 hunks)
  • next-i18next.config.js (1 hunks)
  • pages/_app.tsx (2 hunks)
  • public/locales/de/footer.json (1 hunks)
  • public/locales/en/footer.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • public/locales/en/footer.json
  • public/locales/de/footer.json
🧰 Additional context used
🪛 ESLint
components/footer/Footer.tsx

[error] 3-3: 'useRouter' is defined but never used.

(unused-imports/no-unused-imports)


[error] 3-3: 'useRouter' is defined but never used.

(no-unused-vars)


[error] 16-16: 'currentLanguage' is defined but never used. Allowed unused args must match /^_/u.

(unused-imports/no-unused-vars)


[error] 16-16: 'currentLanguage' is defined but never used.

(no-unused-vars)


[error] 77-77: Replace ·href={link.url}·target='_blank'·rel='noopener·noreferrer'·className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white' with ⏎······················href={link.url}⏎······················target='_blank'⏎······················rel='noopener·noreferrer'⏎······················className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white'⏎····················

(prettier/prettier)


[error] 95-95: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 95-98: Replace ⏎············href='https://netlify.com'·⏎············target='_blank'⏎············ with href='https://netlify.com'·target='_blank'

(prettier/prettier)


[error] 96-96: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 99-99: Insert ··

(prettier/prettier)


[error] 100-100: Insert ···

(prettier/prettier)


[error] 101-101: Insert ··

(prettier/prettier)


[error] 102-102: Insert ·

(prettier/prettier)


[error] 103-103: Replace ················/>·········· with ··············/>

(prettier/prettier)


[error] 103-103: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 104-104: Delete ······

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project
components/footer/Footer.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 3-3: 'useRouter' is defined but never used. unused-imports/no-unused-imports


[error] 3-3: 'useRouter' is defined but never used. no-unused-vars


[warning] 16-16: Missing JSDoc comment. require-jsdoc


[error] 16-16: 'currentLanguage' is defined but never used. Allowed unused args must match /^_/u. unused-imports/no-unused-vars


[error] 16-16: 'currentLanguage' is defined but never used. no-unused-vars


[warning] 39-39: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 57-57: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 71-71: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 77-77: Replace ·href={link.url}·target='_blank'·rel='noopener·noreferrer'·className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white' with ⏎······················href={link.url}⏎······················target='_blank'⏎······················rel='noopener·noreferrer'⏎······················className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white'⏎···················· prettier/prettier


[warning] 90-90: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 95-95: Trailing spaces not allowed. no-trailing-spaces


[error] 95-95: Replace ⏎············href='https://netlify.com'·⏎············target='_blank'⏎············ with href='https://netlify.com'·target='_blank' prettier/prettier


[error] 96-96: Trailing spaces not allowed. no-trailing-spaces


[error] 99-99: Insert ·· prettier/prettier


[error] 100-100: Insert ··· prettier/prettier


[error] 101-101: Insert ·· prettier/prettier


[error] 102-102: Insert · prettier/prettier


[error] 103-103: Replace ················/>·········· with ··············/> prettier/prettier


[error] 103-103: Trailing spaces not allowed. no-trailing-spaces


[error] 104-104: Delete ······ prettier/prettier

🔇 Additional comments (3)
next-i18next.config.js (1)

5-5: LGTM! Configuration updated correctly for footer translations.

The addition of the 'footer' namespace to the configuration is necessary for supporting the footer translations.

pages/_app.tsx (1)

21-21: LGTM! Language context properly integrated.

The locale is correctly extracted from the router and passed to the Footer component, enabling language-aware rendering.

Also applies to: 40-40

components/footer/Footer.tsx (1)

16-109: LGTM! Footer internationalization implemented correctly.

The implementation correctly uses the translation hook and keys to render the footer content in different languages. The component structure and styling are well-organized.

🧰 Tools
🪛 ESLint

[error] 16-16: 'currentLanguage' is defined but never used. Allowed unused args must match /^_/u.

(unused-imports/no-unused-vars)


[error] 16-16: 'currentLanguage' is defined but never used.

(no-unused-vars)


[error] 77-77: Replace ·href={link.url}·target='_blank'·rel='noopener·noreferrer'·className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white' with ⏎······················href={link.url}⏎······················target='_blank'⏎······················rel='noopener·noreferrer'⏎······················className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white'⏎····················

(prettier/prettier)


[error] 95-95: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 95-98: Replace ⏎············href='https://netlify.com'·⏎············target='_blank'⏎············ with href='https://netlify.com'·target='_blank'

(prettier/prettier)


[error] 96-96: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 99-99: Insert ··

(prettier/prettier)


[error] 100-100: Insert ···

(prettier/prettier)


[error] 101-101: Insert ··

(prettier/prettier)


[error] 102-102: Insert ·

(prettier/prettier)


[error] 103-103: Replace ················/>·········· with ··············/>

(prettier/prettier)


[error] 103-103: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 104-104: Delete ······

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[warning] 16-16: Missing JSDoc comment. require-jsdoc


[error] 16-16: 'currentLanguage' is defined but never used. Allowed unused args must match /^_/u. unused-imports/no-unused-vars


[error] 16-16: 'currentLanguage' is defined but never used. no-unused-vars


[warning] 39-39: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 57-57: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 71-71: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 77-77: Replace ·href={link.url}·target='_blank'·rel='noopener·noreferrer'·className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white' with ⏎······················href={link.url}⏎······················target='_blank'⏎······················rel='noopener·noreferrer'⏎······················className='flex·items-center·gap-2·text-cool-gray·transition·hover:text-white'⏎···················· prettier/prettier


[warning] 90-90: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[error] 95-95: Trailing spaces not allowed. no-trailing-spaces


[error] 95-95: Replace ⏎············href='https://netlify.com'·⏎············target='_blank'⏎············ with href='https://netlify.com'·target='_blank' prettier/prettier


[error] 96-96: Trailing spaces not allowed. no-trailing-spaces


[error] 99-99: Insert ·· prettier/prettier


[error] 100-100: Insert ··· prettier/prettier


[error] 101-101: Insert ·· prettier/prettier


[error] 102-102: Insert · prettier/prettier


[error] 103-103: Replace ················/>·········· with ··············/> prettier/prettier


[error] 103-103: Trailing spaces not allowed. no-trailing-spaces


[error] 104-104: Delete ······ prettier/prettier

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] Footer section language not changing when language is changed
2 participants