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

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
MIN_SIDEBAR_WIDTH,
NARROW_SIDEBAR_WIDTH,
Path,
PLUGINS,
REPO_URL,
} from "../constant";

Expand All @@ -32,6 +31,12 @@ import dynamic from "next/dynamic";
import { showConfirm, Selector } from "./ui-lib";
import clsx from "clsx";

const DISCOVERY = [
{ name: Locale.Plugin.Name, path: Path.Plugins },
{ name: "Stable Diffusion", path: Path.Sd },
{ name: Locale.SearchChat.Page.Title, path: Path.SearchChat },
];
Comment on lines +34 to +38
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.


const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
loading: () => null,
});
Expand Down Expand Up @@ -219,7 +224,7 @@ export function SideBarTail(props: {
export function SideBar(props: { className?: string }) {
useHotKey();
const { onDragStart, shouldNarrow } = useDragSideBar();
const [showPluginSelector, setShowPluginSelector] = useState(false);
const [showDiscoverySelector, setshowDiscoverySelector] = useState(false);
const navigate = useNavigate();
const config = useAppConfig();
const chatStore = useChatStore();
Expand Down Expand Up @@ -254,21 +259,21 @@ export function SideBar(props: { className?: string }) {
icon={<DiscoveryIcon />}
text={shouldNarrow ? undefined : Locale.Discovery.Name}
className={styles["sidebar-bar-button"]}
onClick={() => setShowPluginSelector(true)}
onClick={() => setshowDiscoverySelector(true)}
shadow
/>
</div>
{showPluginSelector && (
{showDiscoverySelector && (
<Selector
items={[
...PLUGINS.map((item) => {
...DISCOVERY.map((item) => {
return {
title: item.name,
value: item.path,
};
}),
]}
onClose={() => setShowPluginSelector(false)}
onClose={() => setshowDiscoverySelector(false)}
onSelection={(s) => {
navigate(s[0], { state: { fromHome: true } });
}}
Expand Down
5 changes: 0 additions & 5 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,6 @@ export const internalAllowedWebDavEndpoints = [
];

export const DEFAULT_GA_ID = "G-89WN60ZK2E";
export const PLUGINS = [
{ name: "Plugins", path: Path.Plugins },
{ name: "Stable Diffusion", path: Path.Sd },
{ name: "Search Chat", path: Path.SearchChat },
];

export const SAAS_CHAT_URL = "https://nextchat.dev/chat";
export const SAAS_CHAT_UTM_URL = "https://nextchat.dev/chat?utm=github";
4 changes: 2 additions & 2 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const cn = {
},
},
Lang: {
Name: "Language", // ATTENTION: if you wanna add a new translation, please do not translate this value, leave it as `Language`
Name: "Language", // 注意:如果要添加新的翻译,请不要翻译此值,将它保留为 `Language`
All: "所有语言",
},
Avatar: "头像",
Expand Down Expand Up @@ -630,7 +630,7 @@ const cn = {
Sysmessage: "你是一个助手",
},
SearchChat: {
Name: "搜索",
Name: "搜索聊天记录",
Page: {
Title: "搜索聊天记录",
Search: "输入搜索关键词",
Expand Down
2 changes: 1 addition & 1 deletion app/locales/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Page: {
Title: "搜尋聊天記錄",
Search: "輸入搜尋關鍵詞",
Expand Down
Loading