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

Use i18n for DISCOVERY #5920

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Use i18n for DISCOVERY #5920

wants to merge 1 commit into from

Conversation

fishshi
Copy link

@fishshi fishshi commented Dec 10, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

  • Renamed and relocated the DISCOVERY position
  • Used i18n for options within Discovery

📝 补充信息 | Additional Information

  • Use Page.Title instead of Name for SearchChat, as the latter's semantics in the i18n file seem incomplete (only covering "Search" without "Chat").

Summary by CodeRabbit

  • New Features

    • Introduced a discovery feature in the sidebar, enhancing the user interface for selecting options.
  • Bug Fixes

    • Updated localization strings for improved clarity in both Chinese and Traditional Chinese.
  • Documentation

    • Revised comments in localization files to provide clearer instructions for future translations.

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextchat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 8:06am

Copy link

vercel bot commented Dec 10, 2024

@fishshi is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

The changes in this pull request involve modifications to the sidebar component and localization files. The sidebar.tsx component has been updated to incorporate a new constant DISCOVERY, which replaces the previous PLUGINS constant and changes the state variable from showPluginSelector to showDiscoverySelector. Additionally, the Chinese and Traditional Chinese localization files have been updated for clarity, particularly in the SearchChat sections, enhancing user interface messages without altering the underlying logic.

Changes

File Change Summary
app/components/sidebar.tsx - Added constant DISCOVERY for plugin names and paths.
- Renamed showPluginSelector to showDiscoverySelector.
- Updated onClick handler for DiscoveryIcon and conditional rendering of Selector to use showDiscoverySelector.
- Modified items passed to Selector to derive from DISCOVERY.
- Updated onClose handler for Selector.
app/constant.ts - Removed constant PLUGINS, which defined an array of plugin objects.
app/locales/cn.ts - Updated comment for adding new translations.
- Changed SearchChat Name from "搜索" to "搜索聊天记录".
app/locales/tw.ts - Changed SearchChat Name from "搜尋" to "搜尋聊天記錄".
- Updated Title in SearchChat.Page to "搜尋聊天記錄".

Possibly related PRs

Suggested reviewers

  • Leizhenpeng

Poem

🐰 In the sidebar where options bloom,
Discovery now finds more room.
Search chats with ease, oh what delight,
Clarity shines, making things right!
With paths anew, we hop along,
A joyful tune, a cheerful song! 🎶


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. (Experiment)
  • @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

@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 and nitpick comments (1)
app/locales/cn.ts (1)

632-634: Consider expanding Discovery section translations.

Given that this PR focuses on enhancing i18n for the DISCOVERY feature, consider adding translations for additional Discovery-related UI elements such as:

  • Section descriptions
  • Feature explanations
  • Action buttons
  • Error messages
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 83cea3a and 93c5320.

📒 Files selected for processing (4)
  • app/components/sidebar.tsx (3 hunks)
  • app/constant.ts (0 hunks)
  • app/locales/cn.ts (2 hunks)
  • app/locales/tw.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • app/constant.ts
🔇 Additional comments (5)
app/locales/cn.ts (3)

179-179: LGTM! Comment translation improves clarity for Chinese developers.

The translation of the comment maintains the critical instruction while making it more accessible to Chinese developers.


633-633: LGTM! Improved clarity in search functionality label.

The change from "搜索" to "搜索聊天记录" provides better context about the search functionality, making it clearer that users are specifically searching chat records.


632-634: Verify translation usage in components.

Let's verify how these translations are being used in the components:

✅ Verification successful

Translation changes are properly integrated and used.

The verification shows that:

  1. The SearchChat translation is consistently used across all language files (ar, bn, cn, cs, de, en, es, fr, id, it, jp, ko, no, pt, ru, sk, tr, tw, vi).
  2. The translation is actively used in the search-chat component (app/components/search-chat.tsx) through Locale.SearchChat.Page.Title, Locale.SearchChat.Page.SubTitle, and Locale.SearchChat.Item.View.
  3. The component is properly integrated into the application's routing system via Path.SearchChat constant.
  4. The changes in the Chinese translation file (cn.ts) align with the translation structure used throughout the application.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of SearchChat and Discovery translations
echo "Searching for SearchChat translation usage..."
rg -A 2 "SearchChat.*Name" --type ts --type tsx

echo "Searching for Discovery translation usage..."
rg -A 2 "Discovery.*Name" --type ts --type tsx

Length of output: 354


Script:

#!/bin/bash
# Search for SearchChat translation usage with correct file type
echo "Searching for SearchChat translation usage..."
rg "SearchChat" --type typescript

# Search for files that might be using these translations
echo -e "\nSearching for potential component files..."
fd -e tsx -e ts

Length of output: 3465


Script:

#!/bin/bash
# Search for SearchChat usage with rg without file type specification
echo "Searching for SearchChat usage..."
rg "SearchChat" -A 2

# Specifically check the search-chat component
echo -e "\nChecking search-chat component implementation..."
cat app/components/search-chat.tsx

Length of output: 9163

app/components/sidebar.tsx (2)

227-227: LGTM: State variable renamed appropriately

The state variable rename from showPluginSelector to showDiscoverySelector aligns with the new Discovery feature and maintains clear naming conventions.


262-262: Implementation looks good, verify path constants

The UI interaction changes are implemented correctly, maintaining the same user experience while updating to use the new Discovery feature.

Let's verify that all paths used in the DISCOVERY constant are properly defined:

Also applies to: 266-276

✅ Verification successful

Path constants are properly defined and used correctly

The verification confirms that all paths used in the DISCOVERY constant (Path.Plugins, Path.Sd, Path.SearchChat) are properly defined in the Path enum in app/constant.ts and are used consistently throughout the codebase. The implementation maintains proper type safety and routing integrity.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all paths used in DISCOVERY are defined in Path constant

# Search for Path constant definition
echo "Searching for Path constant definition..."
rg --type typescript "export (?:const|enum|type) Path\s*=" -A 10

# Verify specific path usage
echo "Verifying specific paths..."
rg --type typescript "Path\.(Plugins|Sd|SearchChat)\b" -A 1

Length of output: 356


Script:

#!/bin/bash
# Let's try without typescript file type specification and search for Path definitions
echo "Searching for Path constant definition..."
rg "export (?:const|enum|type) Path\s*=" -A 10

# Search for DISCOVERY constant to understand path usage
echo "Searching for DISCOVERY constant..."
rg "export const DISCOVERY\s*=" -A 10

# Search for specific path usages without typescript specification
echo "Verifying path usages..."
rg "Path\.(Plugins|Sd|SearchChat)\b" -A 1

Length of output: 1401


Script:

#!/bin/bash
# Let's find the Path enum/constant definition
echo "Searching for Path definition in constants or types..."
rg -g "*.{ts,tsx}" "(?:enum|const|type)\s+Path\s*[=]?" -B 2 -A 10

# Also search for any imports of Path to find its source
echo "Searching for Path imports..."
rg -g "*.{ts,tsx}" "import.*Path.*from" -B 1 -A 1

Length of output: 4356

@@ -485,7 +485,7 @@ const tw = {
},
},
SearchChat: {
Name: "搜尋",
Name: "搜尋聊天記錄",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Translations need to be updated for consistency across language files

Only Traditional Chinese (tw) and Simplified Chinese (cn) use the more descriptive "Search Chat Records" translation, while other languages use a simpler "Search" translation. For consistency in user experience:

  • Update the following translations to be more descriptive about searching chat records:
    • English (en): "Search" → "Search Chat"
    • Japanese (jp): "検索" → "チャット検索"
    • Korean (ko): "검색" → "채팅 검색"
    • Spanish (es): "Buscar" → "Buscar Chat"
    • French (fr): "Recherche" → "Rechercher les discussions"
    • German (de): "Suche" → "Chat durchsuchen"
    • And similar descriptive updates for other language files
🔗 Analysis chain

LGTM! The translation update improves clarity.

The change from "搜尋" to "搜尋聊天記錄" makes the functionality clearer by explicitly stating that the search is for chat records.

Let's verify the consistency of this translation across other language files:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the SearchChat.Name translation is consistent across language files
# Expected: All language files should have similarly descriptive translations

# Search for SearchChat.Name in all locale files
rg -A 1 "SearchChat: \{" app/locales/

Length of output: 1450

Comment on lines +34 to +38
const DISCOVERY = [
{ name: Locale.Plugin.Name, path: Path.Plugins },
{ name: "Stable Diffusion", path: Path.Sd },
{ name: Locale.SearchChat.Page.Title, path: Path.SearchChat },
];
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Maintain i18n consistency across all DISCOVERY items

The "Stable Diffusion" string is hardcoded while other entries use localization. This inconsistency could cause issues when supporting multiple languages.

Consider using i18n for all strings:

 const DISCOVERY = [
   { name: Locale.Plugin.Name, path: Path.Plugins },
-  { name: "Stable Diffusion", path: Path.Sd },
+  { name: Locale.Discovery.StableDiffusion, path: Path.Sd },
   { name: Locale.SearchChat.Page.Title, path: Path.SearchChat },
 ];

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

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.

1 participant