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: fixed text on the events page two buttons and linked it to the common.json file #3488

Conversation

BalrajDhakad
Copy link

@BalrajDhakad BalrajDhakad commented Dec 19, 2024

-Screenshots

With Error

Screenshot 2024-12-19 at 6 42 13 PM

Fixed

Screenshot 2024-12-19 at 6 42 18 PM

-Description

  • Updated the text on two buttons on the events page under the community section in the navbar and linked those texts to the 'common.json' file.

-Issue resolved

#3465

Summary by CodeRabbit

  • New Features
    • Enhanced internationalization for the Google Calendar and ICS File buttons by sourcing button text from a localization JSON file.
  • Bug Fixes
    • Updated button text retrieval logic to improve localization accuracy.

Copy link

coderabbitai bot commented Dec 19, 2024

Warning

Rate limit exceeded

@BalrajDhakad has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 95df3b9 and 1ff652b.

📒 Files selected for processing (2)
  • components/buttons/GoogleCalendarButton.tsx (3 hunks)
  • components/buttons/ICSFileButton.tsx (3 hunks)

Walkthrough

The pull request introduces localization improvements for two button components: GoogleCalendarButton and ICSFileButton. Both components now dynamically retrieve their button text from a localization JSON file (common.json) instead of using hardcoded strings. This change enhances the internationalization capabilities of the components by centralizing text management and making it easier to support multiple languages in the future.

Changes

File Change Summary
components/buttons/GoogleCalendarButton.tsx Added import from localization JSON file, created googleCalenderBtnText variable, updated button text prop to use localized text
components/buttons/ICSFileButton.tsx Added import from localization JSON file, created icsFileBtnText variable, updated button text prop to use localized text

Poem

🐰 A Rabbit's Localization Ode 🌐
With JSON in paw and text so bright,
Our buttons now speak with localized might!
No more hardcoded strings, oh what a feat,
Internationalization makes our code sweet!
Hop, hop, hooray for dynamic display! 🎉


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 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.

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.

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

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

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 19, 2024

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 43
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3488--asyncapi-website.netlify.app/

Copy link

@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

🔭 Outside diff range comments (1)
components/buttons/GoogleCalendarButton.tsx (1)

Based on the gathered information, I can now provide the final response:

Direct JSON imports should be replaced with proper translation hooks

The codebase shows inconsistent localization implementation:

  • Both GoogleCalendarButton and ICSFileButton components directly import and use the JSON file, which bypasses the i18n system
  • Other components correctly use the useTranslation hook with t() function for translations
  • The translation keys exist in the common.json file but are being accessed incorrectly

Required changes:

  • Remove the direct import of common.json in both button components
  • Replace details.googleCalendarBtn with t('googleCalendarBtn')
  • Replace details.icsFileBtn with t('icsFileBtn')
🔗 Analysis chain

Line range hint 1-42: Verify localization implementation across the application

Let's verify that the localization keys are properly defined in the common.json file and that there are no other direct JSON imports in the codebase.


Let me gather more information about the localization implementation to ensure we have a complete picture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the translation keys exist in common.json
echo "Checking for translation keys in common.json..."
cat public/locales/en/common.json | jq '.googleCalendarBtn, .icsFileBtn'

# Look for other direct imports of JSON locale files
echo "Checking for other direct JSON imports..."
rg "from.*locales.*common.json"

Length of output: 550


Script:

#!/bin/bash
# Check for other uses of useTranslation
echo "Checking for useTranslation usage patterns..."
rg "useTranslation" -A 2

# Check for direct variable usage from JSON files
echo "Checking for direct usage of imported JSON variables..."
ast-grep --pattern 'details.$_'

# Check for other translation patterns
echo "Looking for t() function calls..."
rg "t\(['\"].*['\"]" --type ts --type tsx

Length of output: 10591

🧰 Tools
🪛 eslint

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

(no-trailing-spaces)


[error] 29-30: Replace ··⏎ with ⏎··

(prettier/prettier)


[error] 32-32: Insert ··

(prettier/prettier)


[error] 32-32: 'googleCalenderBtnText' is never reassigned. Use 'const' instead.

(prefer-const)

🧹 Nitpick comments (1)
components/buttons/ICSFileButton.tsx (1)

30-33: Clean up variable declaration and comment

The variable declaration and comment can be removed as they're not necessary when using the translation key directly. If you need to keep the variable, it should use const since it's never reassigned.

-// created a variable with name 'icsFileBtnText' to take the value from 'common.json' file to add text on the button
-
-let icsFileBtnText = details.icsFileBtn;
🧰 Tools
🪛 eslint

[error] 30-30: Insert ··

(prettier/prettier)


[error] 32-32: Insert ··

(prettier/prettier)


[error] 32-32: 'icsFileBtnText' is never reassigned. Use 'const' instead.

(prefer-const)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c90b564 and 3cbb46a.

📒 Files selected for processing (2)
  • components/buttons/GoogleCalendarButton.tsx (2 hunks)
  • components/buttons/ICSFileButton.tsx (2 hunks)
🧰 Additional context used
🪛 eslint
components/buttons/ICSFileButton.tsx

[error] 1-9: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 30-30: Insert ··

(prettier/prettier)


[error] 32-32: Insert ··

(prettier/prettier)


[error] 32-32: 'icsFileBtnText' is never reassigned. Use 'const' instead.

(prefer-const)

components/buttons/GoogleCalendarButton.tsx

[error] 1-9: Run autofix to sort these imports!

(simple-import-sort/imports)


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

(no-trailing-spaces)


[error] 29-30: Replace ··⏎ with ⏎··

(prettier/prettier)


[error] 32-32: Insert ··

(prettier/prettier)


[error] 32-32: 'googleCalenderBtnText' is never reassigned. Use 'const' instead.

(prefer-const)

🔇 Additional comments (1)
components/buttons/GoogleCalendarButton.tsx (1)

9-9: Avoid direct import of JSON locale files

Same issue as in ICSFileButton.tsx - direct imports of JSON locale files should be avoided.

🧰 Tools
🪛 eslint

[error] 1-9: Run autofix to sort these imports!

(simple-import-sort/imports)

components/buttons/ICSFileButton.tsx Show resolved Hide resolved
components/buttons/GoogleCalendarButton.tsx Outdated Show resolved Hide resolved
@BalrajDhakad BalrajDhakad changed the title Fixed text on the events page two buttons and linked it to the common.json file fixed text on the events page two buttons and linked it to the common.json file Dec 19, 2024
@BalrajDhakad BalrajDhakad changed the title fixed text on the events page two buttons and linked it to the common.json file fix: fixed text on the events page two buttons and linked it to the common.json file Dec 19, 2024
@anshgoyalevil
Copy link
Member

That's not how this issue has to be resolved. A new page with translations API has to be created. Closing this PR.

@BalrajDhakad
Copy link
Author

Can you please elaborate a bit more on how this issue should be resolved.

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.

3 participants