From 05a868550460bce5283e1fe4b529a9dc78a3a2fc Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 19 Apr 2025 20:37:09 +0800 Subject: [PATCH] . --- .../items/assistants/assistant-item.tsx | 18 ++++++----- .../assistants/assistant-retrieval-select.tsx | 8 +++-- .../assistants/assistant-tool-select.tsx | 8 +++-- .../collections/collection-file-select.tsx | 8 +++-- .../items/collections/collection-item.tsx | 15 ++++++---- .../items/collections/create-collection.tsx | 12 +++++--- .../sidebar/items/files/create-file.tsx | 14 +++++---- components/sidebar/items/files/file-item.tsx | 12 ++++---- .../sidebar/items/folders/delete-folder.tsx | 12 ++++---- .../sidebar/items/folders/update-folder.tsx | 10 ++++--- .../sidebar/items/models/create-model.tsx | 30 +++++++++++-------- public/locales/en/translation.json | 28 ++++++++++++++++- public/locales/ja/translation.json | 28 ++++++++++++++++- public/locales/zh/translation.json | 28 ++++++++++++++++- 14 files changed, 174 insertions(+), 57 deletions(-) diff --git a/components/sidebar/items/assistants/assistant-item.tsx b/components/sidebar/items/assistants/assistant-item.tsx index de807fd..823ac57 100644 --- a/components/sidebar/items/assistants/assistant-item.tsx +++ b/components/sidebar/items/assistants/assistant-item.tsx @@ -13,11 +13,15 @@ import { SidebarItem } from "../all/sidebar-display-item" import { AssistantRetrievalSelect } from "./assistant-retrieval-select" import { AssistantToolSelect } from "./assistant-tool-select" +import { useTranslation } from 'react-i18next' + interface AssistantItemProps { assistant: Tables<"assistants"> } export const AssistantItem: FC = ({ assistant }) => { + const { t } = useTranslation() + const { selectedWorkspace, assistantImages } = useContext(ChatbotUIContext) const [name, setName] = useState(assistant.name) @@ -167,10 +171,10 @@ export const AssistantItem: FC = ({ assistant }) => { }) => ( <>
- + setName(e.target.value)} maxLength={ASSISTANT_NAME_MAX} @@ -178,10 +182,10 @@ export const AssistantItem: FC = ({ assistant }) => {
- + setDescription(e.target.value)} maxLength={ASSISTANT_DESCRIPTION_MAX} @@ -189,7 +193,7 @@ export const AssistantItem: FC = ({ assistant }) => {
- + = ({ assistant }) => { />
- + = ({ assistant }) => {
- + [] | Tables<"collections">[] onAssistantRetrievalItemsSelect: ( @@ -26,6 +28,8 @@ export const AssistantRetrievalSelect: FC = ({ selectedAssistantRetrievalItems, onAssistantRetrievalItemsSelect }) => { + const { t } = useTranslation() + const { files, collections } = useContext(ChatbotUIContext) const inputRef = useRef(null) @@ -67,7 +71,7 @@ export const AssistantRetrievalSelect: FC = ({ >
- {selectedAssistantRetrievalItems.length} files selected + {selectedAssistantRetrievalItems.length} {t("side.filesSelected")}
@@ -82,7 +86,7 @@ export const AssistantRetrievalSelect: FC = ({ > setSearch(e.target.value)} onKeyDown={e => e.stopPropagation()} diff --git a/components/sidebar/items/assistants/assistant-tool-select.tsx b/components/sidebar/items/assistants/assistant-tool-select.tsx index 2efba48..73af4d5 100644 --- a/components/sidebar/items/assistants/assistant-tool-select.tsx +++ b/components/sidebar/items/assistants/assistant-tool-select.tsx @@ -14,6 +14,8 @@ import { } from "@tabler/icons-react" import { FC, useContext, useEffect, useRef, useState } from "react" +import { useTranslation } from 'react-i18next' + interface AssistantToolSelectProps { selectedAssistantTools: Tables<"tools">[] onAssistantToolsSelect: (tool: Tables<"tools">) => void @@ -23,6 +25,8 @@ export const AssistantToolSelect: FC = ({ selectedAssistantTools, onAssistantToolsSelect }) => { + const { t } = useTranslation() + const { tools } = useContext(ChatbotUIContext) const inputRef = useRef(null) @@ -64,7 +68,7 @@ export const AssistantToolSelect: FC = ({ >
- {selectedAssistantTools.length} tools selected + {selectedAssistantTools.length} {t("side.toolsSelected")}
@@ -79,7 +83,7 @@ export const AssistantToolSelect: FC = ({ > setSearch(e.target.value)} onKeyDown={e => e.stopPropagation()} diff --git a/components/sidebar/items/collections/collection-file-select.tsx b/components/sidebar/items/collections/collection-file-select.tsx index 7f2f0de..2c1f96f 100644 --- a/components/sidebar/items/collections/collection-file-select.tsx +++ b/components/sidebar/items/collections/collection-file-select.tsx @@ -11,6 +11,8 @@ import { CollectionFile } from "@/types" import { IconChevronDown, IconCircleCheckFilled } from "@tabler/icons-react" import { FC, useContext, useEffect, useRef, useState } from "react" +import { useTranslation } from 'react-i18next' + interface CollectionFileSelectProps { selectedCollectionFiles: CollectionFile[] onCollectionFileSelect: (file: CollectionFile) => void @@ -20,6 +22,8 @@ export const CollectionFileSelect: FC = ({ selectedCollectionFiles, onCollectionFileSelect }) => { + const { t } = useTranslation() + const { files } = useContext(ChatbotUIContext) const inputRef = useRef(null) @@ -61,7 +65,7 @@ export const CollectionFileSelect: FC = ({ >
- {selectedCollectionFiles.length} files selected + {selectedCollectionFiles.length} {t("side.filesSelected")}
@@ -76,7 +80,7 @@ export const CollectionFileSelect: FC = ({ > setSearch(e.target.value)} onKeyDown={e => e.stopPropagation()} diff --git a/components/sidebar/items/collections/collection-item.tsx b/components/sidebar/items/collections/collection-item.tsx index e6b1faa..a9bd861 100644 --- a/components/sidebar/items/collections/collection-item.tsx +++ b/components/sidebar/items/collections/collection-item.tsx @@ -8,11 +8,16 @@ import { FC, useState } from "react" import { SidebarItem } from "../all/sidebar-display-item" import { CollectionFileSelect } from "./collection-file-select" +import { useTranslation } from 'react-i18next' + interface CollectionItemProps { collection: Tables<"collections"> } export const CollectionItem: FC = ({ collection }) => { + + const { t } = useTranslation() + const [name, setName] = useState(collection.name) const [isTyping, setIsTyping] = useState(false) const [description, setDescription] = useState(collection.description) @@ -59,7 +64,7 @@ export const CollectionItem: FC = ({ collection }) => { return ( <>
- + = ({ collection }) => {
- + setName(e.target.value)} maxLength={COLLECTION_NAME_MAX} @@ -100,10 +105,10 @@ export const CollectionItem: FC = ({ collection }) => {
- + setDescription(e.target.value)} maxLength={COLLECTION_DESCRIPTION_MAX} diff --git a/components/sidebar/items/collections/create-collection.tsx b/components/sidebar/items/collections/create-collection.tsx index d2c2437..d4056cc 100644 --- a/components/sidebar/items/collections/create-collection.tsx +++ b/components/sidebar/items/collections/create-collection.tsx @@ -8,6 +8,8 @@ import { CollectionFile } from "@/types" import { FC, useContext, useState } from "react" import { CollectionFileSelect } from "./collection-file-select" +import { useTranslation } from 'react-i18next' + interface CreateCollectionProps { isOpen: boolean onOpenChange: (isOpen: boolean) => void @@ -17,6 +19,8 @@ export const CreateCollection: FC = ({ isOpen, onOpenChange }) => { + const { t } = useTranslation() + const { profile, selectedWorkspace } = useContext(ChatbotUIContext) const [name, setName] = useState("") @@ -64,7 +68,7 @@ export const CreateCollection: FC = ({ renderInputs={() => ( <>
- + = ({
- + = ({
- + setDescription(e.target.value)} maxLength={COLLECTION_DESCRIPTION_MAX} diff --git a/components/sidebar/items/files/create-file.tsx b/components/sidebar/items/files/create-file.tsx index 20220d3..3a9a69f 100644 --- a/components/sidebar/items/files/create-file.tsx +++ b/components/sidebar/items/files/create-file.tsx @@ -7,12 +7,16 @@ import { FILE_DESCRIPTION_MAX, FILE_NAME_MAX } from "@/db/limits" import { TablesInsert } from "@/supabase/types" import { FC, useContext, useState } from "react" +import { useTranslation } from 'react-i18next' + interface CreateFileProps { isOpen: boolean onOpenChange: (isOpen: boolean) => void } export const CreateFile: FC = ({ isOpen, onOpenChange }) => { + const { t } = useTranslation() + const { profile, selectedWorkspace } = useContext(ChatbotUIContext) const [name, setName] = useState("") @@ -56,7 +60,7 @@ export const CreateFile: FC = ({ isOpen, onOpenChange }) => { renderInputs={() => ( <>
- + = ({ isOpen, onOpenChange }) => {
- + setName(e.target.value)} maxLength={FILE_NAME_MAX} @@ -77,10 +81,10 @@ export const CreateFile: FC = ({ isOpen, onOpenChange }) => {
- + setDescription(e.target.value)} maxLength={FILE_DESCRIPTION_MAX} diff --git a/components/sidebar/items/files/file-item.tsx b/components/sidebar/items/files/file-item.tsx index 7941e2e..10758a3 100644 --- a/components/sidebar/items/files/file-item.tsx +++ b/components/sidebar/items/files/file-item.tsx @@ -6,12 +6,14 @@ import { getFileFromStorage } from "@/db/storage/files" import { Tables } from "@/supabase/types" import { FC, useState } from "react" import { SidebarItem } from "../all/sidebar-display-item" +import { useTranslation } from 'react-i18next' interface FileItemProps { file: Tables<"files"> } export const FileItem: FC = ({ file }) => { + const { t } = useTranslation() const [name, setName] = useState(file.name) const [isTyping, setIsTyping] = useState(false) const [description, setDescription] = useState(file.description) @@ -34,7 +36,7 @@ export const FileItem: FC = ({ file }) => { className="cursor-pointer underline hover:opacity-50" onClick={getLinkAndView} > - View {file.name} + {t("side.view")} {file.name}
@@ -46,10 +48,10 @@ export const FileItem: FC = ({ file }) => {
- + setName(e.target.value)} maxLength={FILE_NAME_MAX} @@ -57,10 +59,10 @@ export const FileItem: FC = ({ file }) => {
- + setDescription(e.target.value)} maxLength={FILE_DESCRIPTION_MAX} diff --git a/components/sidebar/items/folders/delete-folder.tsx b/components/sidebar/items/folders/delete-folder.tsx index 8a6fb0f..1de9044 100644 --- a/components/sidebar/items/folders/delete-folder.tsx +++ b/components/sidebar/items/folders/delete-folder.tsx @@ -16,6 +16,7 @@ import { ContentType } from "@/types" import { IconTrash } from "@tabler/icons-react" import { FC, useContext, useRef, useState } from "react" import { toast } from "sonner" +import { useTranslation } from 'react-i18next' interface DeleteFolderProps { folder: Tables<"folders"> @@ -26,6 +27,7 @@ export const DeleteFolder: FC = ({ folder, contentType }) => { + const { t } = useTranslation() const { setChats, setFolders, @@ -107,16 +109,16 @@ export const DeleteFolder: FC = ({ - Delete {folder.name} + {t("side.delete")} {folder.name} - Are you sure you want to delete this folder? + {t("side.confirmDeleteFolder")} diff --git a/components/sidebar/items/folders/update-folder.tsx b/components/sidebar/items/folders/update-folder.tsx index d98833e..067169d 100644 --- a/components/sidebar/items/folders/update-folder.tsx +++ b/components/sidebar/items/folders/update-folder.tsx @@ -14,12 +14,14 @@ import { updateFolder } from "@/db/folders" import { Tables } from "@/supabase/types" import { IconEdit } from "@tabler/icons-react" import { FC, useContext, useRef, useState } from "react" +import { useTranslation } from 'react-i18next' interface UpdateFolderProps { folder: Tables<"folders"> } export const UpdateFolder: FC = ({ folder }) => { + const { t } = useTranslation() const { setFolders } = useContext(ChatbotUIContext) const buttonRef = useRef(null) @@ -52,22 +54,22 @@ export const UpdateFolder: FC = ({ folder }) => { - Edit Folder + {t("side.editFolder")}
- + setName(e.target.value)} />
diff --git a/components/sidebar/items/models/create-model.tsx b/components/sidebar/items/models/create-model.tsx index c50ea63..2c80c69 100644 --- a/components/sidebar/items/models/create-model.tsx +++ b/components/sidebar/items/models/create-model.tsx @@ -5,6 +5,7 @@ import { ChatbotUIContext } from "@/context/context" import { MODEL_NAME_MAX } from "@/db/limits" import { TablesInsert } from "@/supabase/types" import { FC, useContext, useState } from "react" +import { useTranslation, Trans } from 'react-i18next' interface CreateModelProps { isOpen: boolean @@ -12,6 +13,7 @@ interface CreateModelProps { } export const CreateModel: FC = ({ isOpen, onOpenChange }) => { + const { t } = useTranslation() const { profile, selectedWorkspace } = useContext(ChatbotUIContext) const [isTyping, setIsTyping] = useState(false) @@ -45,19 +47,20 @@ export const CreateModel: FC = ({ isOpen, onOpenChange }) => { renderInputs={() => ( <>
-
Create a custom model.
+
{t("side.createCustomModel")}
- Your API *must* be compatible - with the OpenAI SDK. + {/* Your API *must* be compatible + with the OpenAI SDK. */} + }} />
- + setName(e.target.value)} maxLength={MODEL_NAME_MAX} @@ -65,42 +68,43 @@ export const CreateModel: FC = ({ isOpen, onOpenChange }) => {
- + setModelId(e.target.value)} />
- + setBaseUrl(e.target.value)} />
- Your API must be compatible with the OpenAI SDK. + {t("side.apiCompatibilityNotice")} +
- + setApiKey(e.target.value)} />
- + *must* be compatible with the OpenAI SDK.", + "apiCompatibilityNotice": "Your API must be compatible with the OpenAI SDK.", + "modelNamePlaceholder": "Model name...", + "modelId": "Model ID", + "modelIdPlaceholder": "Model ID...", + "baseUrl": "Base URL", + "baseUrlPlaceholder": "Base URL...", + "apiKey": "API Key", + "apiKeyPlaceholder": "API Key...", + "maxContextLength": "Max Context Length" }, "contentType": { diff --git a/public/locales/ja/translation.json b/public/locales/ja/translation.json index 5d905cd..182d10a 100644 --- a/public/locales/ja/translation.json +++ b/public/locales/ja/translation.json @@ -165,7 +165,33 @@ "editChat": "チャットを編集", "confirmDelete": "本当に削除しますか?", "edit": "編集", - "assignedWorkspaces": "割り当てられたワークスペース" + "assignedWorkspaces": "割り当てられたワークスペース", + "searchFilesPlaceholder": "ファイルを検索...", + "filesSelected": "件のファイルが選択されました", + "toolsSelected": "件のツールが選択されました", + "searchToolsPlaceholder": "ツールを検索...", + "files": "ファイル", + "file": "ファイル", + "collectionDescriptionPlaceholder": "コレクションの説明...", + "collectionNamePlaceholder": "コレクション名...", + "fileNamePlaceholder": "ファイル名...", + "fileDescriptionPlaceholder": "ファイルの説明...", + "view": "表示", + "confirmDeleteFolder": "このフォルダーを削除してもよろしいですか?", + "deleteFolderWithContents": "フォルダーと含まれる項目を削除", + "deleteFolderOnly": "フォルダーのみ削除", + "editFolder": "フォルダーを編集", + "createCustomModel": "カスタムモデルを作成します。", + "apiCompatibilityWarning": "あなたの API は *完全に* OpenAI SDK と互換である必要があります。", + "apiCompatibilityNotice": "あなたの API は OpenAI SDK と互換である必要があります。", + "modelNamePlaceholder": "モデル名...", + "modelId": "モデル ID", + "modelIdPlaceholder": "モデル ID...", + "baseUrl": "ベース URL", + "baseUrlPlaceholder": "ベース URL...", + "apiKey": "API キー", + "apiKeyPlaceholder": "API キー...", + "maxContextLength": "最大コンテキスト長" }, "contentType": { diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 4e3e5e6..9ed880f 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -165,7 +165,33 @@ "editChat": "编辑对话", "confirmDelete": "你确定要删除吗?", "edit": "编辑", - "assignedWorkspaces": "已分配的工作区" + "assignedWorkspaces": "已分配的工作区", + "searchFilesPlaceholder": "搜索文件...", + "filesSelected": "个文件已选择", + "toolsSelected": "个工具已选择", + "searchToolsPlaceholder": "搜索工具...", + "files": "文件", + "file": "文件", + "collectionDescriptionPlaceholder": "集合描述...", + "collectionNamePlaceholder": "集合名称...", + "fileNamePlaceholder": "文件名称...", + "fileDescriptionPlaceholder": "文件描述...", + "view": "查看", + "confirmDeleteFolder": "你确定要删除这个文件夹吗?", + "deleteFolderWithContents": "删除文件夹及其内容", + "deleteFolderOnly": "仅删除文件夹", + "editFolder": "编辑文件夹", + "createCustomModel": "创建自定义模型。", + "apiCompatibilityWarning": "您的 API *必须* 与 OpenAI SDK 兼容。", + "apiCompatibilityNotice": "您的 API 必须与 OpenAI SDK 兼容。", + "modelNamePlaceholder": "模型名称...", + "modelId": "模型 ID", + "modelIdPlaceholder": "模型 ID...", + "baseUrl": "基础地址", + "baseUrlPlaceholder": "基础地址...", + "apiKey": "API 密钥", + "apiKeyPlaceholder": "API 密钥...", + "maxContextLength": "最大上下文长度" }, "contentType": {