This commit is contained in:
hailin 2025-04-19 10:22:05 +08:00
parent 509a0ea3d7
commit 94096979ad
5 changed files with 35 additions and 10 deletions

View File

@ -13,6 +13,8 @@ import { CreatePreset } from "./items/presets/create-preset"
import { CreatePrompt } from "./items/prompts/create-prompt" import { CreatePrompt } from "./items/prompts/create-prompt"
import { CreateTool } from "./items/tools/create-tool" import { CreateTool } from "./items/tools/create-tool"
import { useTranslation } from "react-i18next";
interface SidebarCreateButtonsProps { interface SidebarCreateButtonsProps {
contentType: ContentType contentType: ContentType
hasData: boolean hasData: boolean
@ -22,7 +24,10 @@ export const SidebarCreateButtons: FC<SidebarCreateButtonsProps> = ({
contentType, contentType,
hasData hasData
}) => { }) => {
const { profile, selectedWorkspace, folders, setFolders } =
const { t, i18n } = useTranslation();
const { profile, selectedWorkspace, folders, setFolders } =
useContext(ChatbotUIContext) useContext(ChatbotUIContext)
const { handleNewChat } = useChatHandler() const { handleNewChat } = useChatHandler()
@ -95,13 +100,31 @@ export const SidebarCreateButtons: FC<SidebarCreateButtonsProps> = ({
} }
} }
// 获取当前语言
const language = i18n.language;
// 判断需要大写首字母的语言
const needsUpperCaseFirstLetter = (language: string) => {
const languagesRequiringUpperCase = ['en', 'de', 'fr', 'es', 'it']; // 其他需要大写首字母的语言
return languagesRequiringUpperCase.includes(language);
};
// 对动态内容进行首字母大写的处理
const getCapitalizedContentType = (contentType: string, language: string) => {
if (needsUpperCaseFirstLetter(language)) {
return contentType.charAt(0).toUpperCase() + contentType.slice(1, contentType.length - 1); // 保留去掉最后一个字符
}
return contentType; // 不需要大写的语言返回原始值
};
return ( return (
<div className="flex w-full space-x-2"> <div className="flex w-full space-x-2">
<Button className="flex h-[36px] grow" onClick={getCreateFunction()}> <Button className="flex h-[36px] grow" onClick={getCreateFunction()}>
<IconPlus className="mr-1" size={20} /> <IconPlus className="mr-1" size={20} />
New{" "}
{contentType.charAt(0).toUpperCase() + {t('New')}{" "}
contentType.slice(1, contentType.length - 1)} {getCapitalizedContentType(contentType, language)}
</Button> </Button>
{hasData && ( {hasData && (

View File

@ -291,12 +291,11 @@ export const WorkspaceSettings: FC<WorkspaceSettingsProps> = ({}) => {
<div className="space-x-2"> <div className="space-x-2">
<Button variant="ghost" onClick={() => setIsOpen(false)}> <Button variant="ghost" onClick={() => setIsOpen(false)}>
Cancel {t("side.cancel")}
{t("side.cancel")}
</Button> </Button>
<Button ref={buttonRef} onClick={handleSave}> <Button ref={buttonRef} onClick={handleSave}>
{t("side.save")} {t("side.save")}
</Button> </Button>
</div> </div>
</div> </div>

View File

@ -144,7 +144,8 @@
"aiResponseInstructions": "How would you like the AI to respond in this workspace?", "aiResponseInstructions": "How would you like the AI to respond in this workspace?",
"workspaceNamePlaceholder": "Name...", "workspaceNamePlaceholder": "Name...",
"workspaceBeginSettings": "These are the settings your workspace begins with when selected.", "workspaceBeginSettings": "These are the settings your workspace begins with when selected.",
"workspaceInstructionsPlaceholder": "Instructions... (optional)" "workspaceInstructionsPlaceholder": "Instructions... (optional)",
"sidebarCreateNew": "New"
} }
} }

View File

@ -143,7 +143,8 @@
"aiResponseInstructions": "このワークスペースでAIにどのように応答してほしいですか", "aiResponseInstructions": "このワークスペースでAIにどのように応答してほしいですか",
"workspaceNamePlaceholder": "名前を入力...", "workspaceNamePlaceholder": "名前を入力...",
"workspaceBeginSettings": "これらはワークスペースを選択したときに始まる設定です。", "workspaceBeginSettings": "これらはワークスペースを選択したときに始まる設定です。",
"workspaceInstructionsPlaceholder": "説明...(オプション)" "workspaceInstructionsPlaceholder": "説明...(オプション)",
"sidebarCreateNew": "新規作成"
} }
} }

View File

@ -143,7 +143,8 @@
"aiResponseInstructions": "您希望 AI 在此工作区内如何回应?", "aiResponseInstructions": "您希望 AI 在此工作区内如何回应?",
"workspaceNamePlaceholder": "请输入名称...", "workspaceNamePlaceholder": "请输入名称...",
"workspaceBeginSettings": "这些是选择此工作区时的初始设置。", "workspaceBeginSettings": "这些是选择此工作区时的初始设置。",
"workspaceInstructionsPlaceholder": "说明...(可选)" "workspaceInstructionsPlaceholder": "说明...(可选)",
"sidebarCreateNew": "新建"
} }
} }