This commit is contained in:
parent
379313dde9
commit
07c0e5e145
|
|
@ -29,6 +29,8 @@ import { ContentType } from "@/types"
|
|||
import { FC, useContext, useRef, useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
interface SidebarCreateItemProps {
|
||||
isOpen: boolean
|
||||
isTyping: boolean
|
||||
|
|
@ -46,6 +48,9 @@ export const SidebarCreateItem: FC<SidebarCreateItemProps> = ({
|
|||
createState,
|
||||
isTyping
|
||||
}) => {
|
||||
|
||||
const { t, i18n } = useTranslation()
|
||||
|
||||
const {
|
||||
selectedWorkspace,
|
||||
setChats,
|
||||
|
|
@ -215,6 +220,20 @@ export const SidebarCreateItem: FC<SidebarCreateItemProps> = ({
|
|||
}
|
||||
}
|
||||
|
||||
// 判断是否需要首字母大写(且做 -1 截断)
|
||||
const needsUpperCaseFirstLetter = (language: string) => {
|
||||
const languagesRequiringUpperCase = ['en', 'de', 'fr', 'es', 'it'];
|
||||
return languagesRequiringUpperCase.includes(language);
|
||||
};
|
||||
|
||||
// 处理翻译后的 contentType 文本
|
||||
const getCapitalizedContentType = (translated: string, language: string) => {
|
||||
if (needsUpperCaseFirstLetter(language)) {
|
||||
return translated.charAt(0).toUpperCase() + translated.slice(1, -1); // ✅ 按你的要求保留 .slice(1, -1)
|
||||
}
|
||||
return translated;
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet open={isOpen} onOpenChange={onOpenChange}>
|
||||
<SheetContent
|
||||
|
|
@ -225,8 +244,13 @@ export const SidebarCreateItem: FC<SidebarCreateItemProps> = ({
|
|||
<div className="grow overflow-auto">
|
||||
<SheetHeader>
|
||||
<SheetTitle className="text-2xl font-bold">
|
||||
Create{" "}
|
||||
{contentType.charAt(0).toUpperCase() + contentType.slice(1, -1)}
|
||||
{/* Create{" "}
|
||||
{contentType.charAt(0).toUpperCase() + contentType.slice(1, -1)} */}
|
||||
|
||||
{t("side.sidebarCreateNew")}{" "}
|
||||
{getCapitalizedContentType(t(`contentTypeLabel.${contentType}`), i18n.language)}
|
||||
|
||||
|
||||
</SheetTitle>
|
||||
</SheetHeader>
|
||||
|
||||
|
|
@ -240,11 +264,11 @@ export const SidebarCreateItem: FC<SidebarCreateItemProps> = ({
|
|||
variant="outline"
|
||||
onClick={() => onOpenChange(false)}
|
||||
>
|
||||
Cancel
|
||||
{t("side.cancel")}
|
||||
</Button>
|
||||
|
||||
<Button disabled={creating} ref={buttonRef} onClick={handleCreate}>
|
||||
{creating ? "Creating..." : "Create"}
|
||||
{creating ? t("side.creating") : t("side.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</SheetFooter>
|
||||
|
|
|
|||
|
|
@ -151,6 +151,8 @@
|
|||
"profileSettings": "Profile Settings",
|
||||
"deleteChatTitle": "Delete",
|
||||
"deleteChatConfirm": "Are you sure you want to delete this chat?",
|
||||
"create": "Create",
|
||||
"creating": "Creating...",
|
||||
"delete": "Delete"
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@
|
|||
"profileSettings": "プロフィール設定",
|
||||
"deleteChatTitle": "削除",
|
||||
"deleteChatConfirm": "このチャットを削除してもよろしいですか?",
|
||||
"create": "作成",
|
||||
"creating": "作成中...",
|
||||
"delete": "削除"
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,8 @@
|
|||
"profileSettings": "个人资料设置",
|
||||
"deleteChatTitle": "删除",
|
||||
"deleteChatConfirm": "您确定要删除此聊天记录吗?",
|
||||
"create": "创建",
|
||||
"creating": "正在创建...",
|
||||
"delete": "删除"
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue