From 80a50633eaa5599efebae5c615709255e7d6f478 Mon Sep 17 00:00:00 2001 From: crazywoola <100913391+crazywoola@users.noreply.github.com> Date: Sat, 5 Apr 2025 11:36:03 +0800 Subject: [PATCH] Revert "fix: move hardcoded text to language settings (#16990) (#17133)" This reverts commit 16c722d1d87c8e75ceced96fcc6a1aa7c09d362d. --- api/core/rag/retrieval/dataset_retrieval.py | 6 +----- .../utils/dataset_retriever/dataset_retriever_tool.py | 6 +----- api/services/dataset_service.py | 6 +----- web/app/(commonLayout)/datasets/Container.tsx | 2 -- web/app/(commonLayout)/datasets/page.tsx | 4 ++++ web/app/(commonLayout)/plugins/page.tsx | 4 ++++ web/app/components/base/app-icon-picker/ImageInput.tsx | 8 +++----- web/app/components/plugins/plugin-page/index.tsx | 2 -- web/i18n/en-US/common.ts | 5 ----- web/i18n/en-US/plugin.ts | 3 --- web/i18n/zh-Hans/common.ts | 5 ----- web/i18n/zh-Hans/plugin.ts | 3 --- 12 files changed, 14 insertions(+), 40 deletions(-) diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.py index 244611c750..e00c989c9d 100644 --- a/api/core/rag/retrieval/dataset_retrieval.py +++ b/api/core/rag/retrieval/dataset_retrieval.py @@ -52,7 +52,6 @@ from core.rag.retrieval.template_prompts import ( METADATA_FILTER_USER_PROMPT_2, METADATA_FILTER_USER_PROMPT_3, ) -from core.tools.entities.common_entities import I18nObject from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool from extensions.ext_database import db from libs.json_in_md_parser import parse_and_check_json_markdown @@ -295,10 +294,7 @@ class DatasetRetrieval: for dataset in available_datasets: description = dataset.description if not description: - description = I18nObject( - en_US="useful for when you want to answer queries about the " + dataset.name, - zh_Hans="用于回答关于 " + dataset.name + " 的查询", - ) + description = "useful for when you want to answer queries about the " + dataset.name description = description.replace("\n", "").replace("\r", "") message_tool = PromptMessageTool( diff --git a/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py index fc3b61a191..63260cfac3 100644 --- a/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py +++ b/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py @@ -6,7 +6,6 @@ from core.rag.datasource.retrieval_service import RetrievalService from core.rag.entities.context_entities import DocumentContext from core.rag.models.document import Document as RetrievalDocument from core.rag.retrieval.retrieval_methods import RetrievalMethod -from core.tools.entities.common_entities import I18nObject from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool from extensions.ext_database import db from models.dataset import Dataset @@ -39,10 +38,7 @@ class DatasetRetrieverTool(DatasetRetrieverBaseTool): def from_dataset(cls, dataset: Dataset, **kwargs): description = dataset.description if not description: - description = I18nObject( - en_US="useful for when you want to answer queries about the " + dataset.name, - zh_Hans="用于回答关于 " + dataset.name + " 的查询", - ) + description = "useful for when you want to answer queries about the " + dataset.name description = description.replace("\n", "").replace("\r", "") return cls( diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py index 68c193a6ba..61dc86a028 100644 --- a/api/services/dataset_service.py +++ b/api/services/dataset_service.py @@ -21,7 +21,6 @@ from core.plugin.entities.plugin import ModelProviderID from core.rag.index_processor.constant.built_in_field import BuiltInField from core.rag.index_processor.constant.index_type import IndexType from core.rag.retrieval.retrieval_methods import RetrievalMethod -from core.tools.entities.common_entities import I18nObject from events.dataset_event import dataset_was_deleted from events.document_event import document_was_deleted from extensions.ext_database import db @@ -1379,10 +1378,7 @@ class DocumentService: cut_length = 18 cut_name = documents[0].name[:cut_length] dataset.name = cut_name + "..." - dataset.description = I18nObject( - en_US="useful for when you want to answer queries about the " + documents[0].name, - zh_Hans="用于回答关于 " + documents[0].name + " 的查询", - ) + dataset.description = "useful for when you want to answer queries about the " + documents[0].name db.session.commit() return dataset, documents, batch diff --git a/web/app/(commonLayout)/datasets/Container.tsx b/web/app/(commonLayout)/datasets/Container.tsx index 95f8baea12..c1d9950bf3 100644 --- a/web/app/(commonLayout)/datasets/Container.tsx +++ b/web/app/(commonLayout)/datasets/Container.tsx @@ -38,8 +38,6 @@ const Container = () => { const { showExternalApiPanel, setShowExternalApiPanel } = useExternalApiPanel() const [includeAll, { toggle: toggleIncludeAll }] = useBoolean(false) - document.title = `${t('dataset.knowledge')} - Dify` - const options = useMemo(() => { return [ { value: 'dataset', text: t('dataset.datasets') }, diff --git a/web/app/(commonLayout)/datasets/page.tsx b/web/app/(commonLayout)/datasets/page.tsx index 678de47c94..096a1b8979 100644 --- a/web/app/(commonLayout)/datasets/page.tsx +++ b/web/app/(commonLayout)/datasets/page.tsx @@ -4,4 +4,8 @@ const AppList = async () => { return } +export const metadata = { + title: 'Datasets - Dify', +} + export default AppList diff --git a/web/app/(commonLayout)/plugins/page.tsx b/web/app/(commonLayout)/plugins/page.tsx index cc525992fa..a3066311b2 100644 --- a/web/app/(commonLayout)/plugins/page.tsx +++ b/web/app/(commonLayout)/plugins/page.tsx @@ -13,4 +13,8 @@ const PluginList = async () => { ) } +export const metadata = { + title: 'Plugins - Dify', +} + export default PluginList diff --git a/web/app/components/base/app-icon-picker/ImageInput.tsx b/web/app/components/base/app-icon-picker/ImageInput.tsx index 9c0a95c021..a973362ec8 100644 --- a/web/app/components/base/app-icon-picker/ImageInput.tsx +++ b/web/app/components/base/app-icon-picker/ImageInput.tsx @@ -4,7 +4,6 @@ import type { ChangeEvent, FC } from 'react' import { createRef, useEffect, useState } from 'react' import Cropper, { type Area, type CropperProps } from 'react-easy-crop' import classNames from 'classnames' -import { useTranslation } from 'react-i18next' import { ImagePlus } from '../icons/src/vender/line/images' import { useDraggableUploader } from './hooks' @@ -27,7 +26,6 @@ const ImageInput: FC = ({ cropShape, onImageInput, }) => { - const { t } = useTranslation() const [inputImage, setInputImage] = useState<{ file: File; url: string }>() const [isAnimatedImage, setIsAnimatedImage] = useState(false) useEffect(() => { @@ -105,8 +103,8 @@ const ImageInput: FC = ({ ? <>
- {t('common.imageInput.dropImageHere')}  - + Drop your image here, or  + ((e.target as HTMLInputElement).value = '')} @@ -114,7 +112,7 @@ const ImageInput: FC = ({ onChange={handleLocalFileInput} />
-
{t('common.imageInput.supportedFormats')}
+
Supports PNG, JPG, JPEG, WEBP and GIF
: handleShowImage() } diff --git a/web/app/components/plugins/plugin-page/index.tsx b/web/app/components/plugins/plugin-page/index.tsx index eb28e17655..74991938a2 100644 --- a/web/app/components/plugins/plugin-page/index.tsx +++ b/web/app/components/plugins/plugin-page/index.tsx @@ -56,8 +56,6 @@ const PluginPage = ({ const searchParams = useSearchParams() const { replace } = useRouter() - document.title = `${t('plugin.metadata.title')} - Dify` - // just support install one package now const packageId = useMemo(() => { const idStrings = searchParams.get(PACKAGE_IDS_KEY) diff --git a/web/i18n/en-US/common.ts b/web/i18n/en-US/common.ts index fae4be5467..0d8b4158d9 100644 --- a/web/i18n/en-US/common.ts +++ b/web/i18n/en-US/common.ts @@ -652,11 +652,6 @@ const translation = { pagination: { perPage: 'Items per page', }, - imageInput: { - dropImageHere: 'Drop your image here, or', - browse: 'browse', - supportedFormats: 'Supports PNG, JPG, JPEG, WEBP and GIF', - }, } export default translation diff --git a/web/i18n/en-US/plugin.ts b/web/i18n/en-US/plugin.ts index fd1a8c2a05..bdfcfb3e72 100644 --- a/web/i18n/en-US/plugin.ts +++ b/web/i18n/en-US/plugin.ts @@ -1,7 +1,4 @@ const translation = { - metadata: { - title: 'Plugins', - }, category: { all: 'All', models: 'Models', diff --git a/web/i18n/zh-Hans/common.ts b/web/i18n/zh-Hans/common.ts index 18933b0759..583a8c0e23 100644 --- a/web/i18n/zh-Hans/common.ts +++ b/web/i18n/zh-Hans/common.ts @@ -652,11 +652,6 @@ const translation = { pagination: { perPage: '每页显示', }, - imageInput: { - dropImageHere: '将图片拖放到此处,或', - browse: '浏览', - supportedFormats: '支持PNG、JPG、JPEG、WEBP和GIF格式', - }, } export default translation diff --git a/web/i18n/zh-Hans/plugin.ts b/web/i18n/zh-Hans/plugin.ts index 94b81ef1d5..dfd13c6bf0 100644 --- a/web/i18n/zh-Hans/plugin.ts +++ b/web/i18n/zh-Hans/plugin.ts @@ -1,7 +1,4 @@ const translation = { - metadata: { - title: '插件', - }, category: { all: '全部', models: '模型',