Skip to content

fix for i18n#1164

Merged
ahmetskilinc merged 1 commit intostagingfrom
05-30-fix_for_i18n
May 30, 2025
Merged

fix for i18n#1164
ahmetskilinc merged 1 commit intostagingfrom
05-30-fix_for_i18n

Conversation

@ahmetskilinc
Copy link
Contributor

@ahmetskilinc ahmetskilinc commented May 30, 2025

TL;DR

Added translation support for command palette item titles.

What changed?

Wrapped the item.title in the command palette with the translation function t() to enable internationalization of command palette items.

How to test?

  1. Set your application to a non-default language
  2. Open the command palette
  3. Verify that item titles are correctly translated to the selected language

Why make this change?

To improve the user experience for non-English speakers by ensuring command palette items are displayed in the user's preferred language, making the application more accessible to a global audience.

Summary by CodeRabbit

  • New Features
    • Added localization support for command titles in the main command palette, enabling display in multiple languages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 30, 2025

Walkthrough

The change updates the command palette component to display command item titles using a translation function, enabling support for localization of these titles in the user interface.

Changes

File Change Summary
apps/mail/components/context/command-palette-context.tsx Wrapped command item titles with translation function for localization support

Poem

In the palette where commands reside,
Now every title can worldwide glide.
With a simple wrap, translations flow,
Languages blossom, options grow.
A rabbit hops, with joy anew—
The world can read the things you do! 🌍🐇

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file 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.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ahmetskilinc ahmetskilinc marked this pull request as ready for review May 30, 2025 20:16
@ahmetskilinc ahmetskilinc merged commit e710e3f into staging May 30, 2025
2 of 3 checks passed
Copy link
Contributor Author

Merge activity

@ahmetskilinc ahmetskilinc deleted the 05-30-fix_for_i18n branch May 30, 2025 20:17
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40cf7d2 and a9d5877.

📒 Files selected for processing (1)
  • apps/mail/components/context/command-palette-context.tsx (1 hunks)

)}
<div className="ml-2 flex flex-1 flex-col">
<span>{item.title}</span>
<span>{t(item.title)}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify translation key structure and add missing translations.

The change correctly adds i18n support, but there are potential issues with the current approach:

  1. Hardcoded titles: Many command titles are hardcoded English strings (e.g., "Compose Email", "Search Emails" on lines 675, 684) rather than translation keys. The t() function will look for these as keys in translation files.

  2. Inconsistent pattern: The existing group title translation (lines 779-780) uses structured keys like common.commandPalette.groups.${groupKey}, suggesting a more organized approach.

Consider updating hardcoded command titles to use proper translation keys:

-    mailCommands.push({
-      title: 'Compose Email',
-      icon: Pencil2,
+    mailCommands.push({
+      title: 'common.commandPalette.commands.composeEmail',
+      icon: Pencil2,

Run this script to identify all hardcoded command titles that need translation keys:


🏁 Script executed:

#!/bin/bash
# Find hardcoded string titles in command definitions
rg -A 2 -B 2 "title:\s*['\"](?!common\.)[^'\"]+['\"]" apps/mail/components/context/command-palette-context.tsx

Length of output: 370


🏁 Script executed:

#!/bin/bash
# Find hardcoded string titles in command definitions excluding common.* keys using PCRE2
rg --pcre2 -n -A 2 -B 2 "title:\s*['\"](?!common\.)[^'\"]+['\"]" apps/mail/components/context/command-palette-context.tsx

Length of output: 1235


Ensure all command titles use structured translation keys

The command-palette titles currently include several hardcoded English strings. To prevent missing keys at runtime and maintain consistency with existing group translations (common.commandPalette.groups.*), please convert these titles to structured keys under common.commandPalette.commands.*. Specifically:

• apps/mail/components/context/command-palette-context.tsx
– Line 458: replace 'Unread Emails'common.commandPalette.commands.unreadEmails
– Line 472: replace 'Starred Emails'common.commandPalette.commands.starredEmails
– Line 486: replace 'With Attachments'common.commandPalette.commands.withAttachments
– Line 500: replace 'Last 7 Days'common.commandPalette.commands.last7Days
– Line 675: replace 'Compose Email'common.commandPalette.commands.composeEmail
– Line 684: replace 'Search Emails'common.commandPalette.commands.searchEmails
– Line 694: replace 'Filter Emails'common.commandPalette.commands.filterEmails
– (Optional) Lines 704 & 713 for commented-out commands ('Saved Searches', 'Filter Builder') should become common.commandPalette.commands.savedSearches and common.commandPalette.commands.filterBuilder

Example diff for one command:

-      title: 'Compose Email',
+      title: 'common.commandPalette.commands.composeEmail',

Also update your translation JSON/PO files with matching entries for each new key.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/mail/components/context/command-palette-context.tsx around lines 458,
472, 486, 500, 675, 684, and 694, replace hardcoded English command titles with
structured translation keys under common.commandPalette.commands.* (e.g.,
'Unread Emails' to common.commandPalette.commands.unreadEmails). This ensures
consistent i18n usage and prevents missing keys at runtime. Also update
translation JSON/PO files to include these new keys and optionally do the same
for commented-out commands on lines 704 and 713.

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.

2 participants