chore: tip i18n

This commit is contained in:
Joel
2026-04-20 09:06:44 +08:00
parent 27791ac121
commit 12b2f0ac3b
4 changed files with 45 additions and 3 deletions

View File

@@ -4,6 +4,29 @@ import { fireEvent, render, screen } from '@testing-library/react'
import { InputVarType } from '@/app/components/workflow/types'
import ConfigModalFormFields from '../form-fields'
vi.mock('react-i18next', async () => {
const React = await import('react')
return {
useTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => {
const ns = options?.ns as string | undefined
return ns ? `${ns}.${key}` : key
},
i18n: { language: 'en', changeLanguage: vi.fn() },
}),
Trans: ({ i18nKey, components }: { i18nKey: string, components?: Record<string, ReactNode> }) => (
<span data-i18n-key={i18nKey}>
{i18nKey}
{components?.docLink}
</span>
),
}
})
vi.mock('@/context/i18n', () => ({
useDocLink: () => (path?: string) => `https://docs.example.com${path || ''}`,
}))
vi.mock('@/app/components/base/file-uploader', () => ({
FileUploaderInAttachmentWrapper: ({ onChange }: { onChange: (files: Array<Record<string, unknown>>) => void }) => (
<button
@@ -170,6 +193,9 @@ describe('ConfigModalFormFields', () => {
const textInputView = render(<ConfigModalFormFields {...textInputProps} />)
expect(screen.getByText('variableConfig.hidden')).toBeInTheDocument()
expect(screen.getByText('variableConfig.hiddenDescription')).toBeInTheDocument()
expect(screen.getByRole('link')).toHaveAttribute('href', 'https://docs.example.com/use-dify/nodes/user-input')
expect(screen.getByRole('link')).toHaveAttribute('target', '_blank')
expect(screen.getByRole('link')).toHaveAttribute('rel', 'noopener noreferrer')
textInputView.unmount()
const singleFileProps = createBaseProps()

View File

@@ -5,6 +5,7 @@ import type { FileEntity } from '@/app/components/base/file-uploader/types'
import type { InputVar, UploadFileSetting } from '@/app/components/workflow/types'
import { RiQuestionLine } from '@remixicon/react'
import * as React from 'react'
import { Trans } from 'react-i18next'
import Checkbox from '@/app/components/base/checkbox'
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
import Input from '@/app/components/base/input'
@@ -21,6 +22,7 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/
import FileUploadSetting from '@/app/components/workflow/nodes/_base/components/file-upload-setting'
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
import { InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types'
import { useDocLink } from '@/context/i18n'
import { TransferMethod } from '@/types/app'
import ConfigSelect from '../config-select'
import ConfigString from '../config-string'
@@ -69,6 +71,7 @@ const ConfigModalFormFields: FC<ConfigModalFormFieldsProps> = ({
}) => {
const { type, label, variable } = tempPayload
const isFileInput = [InputVarType.singleFile, InputVarType.multiFiles].includes(type)
const docLink = useDocLink()
return (
<div className="space-y-2">
@@ -232,7 +235,20 @@ const ConfigModalFormFields: FC<ConfigModalFormFieldsProps> = ({
</div>
</TooltipTrigger>
<TooltipContent>
{t('variableConfig.hiddenDescription', { ns: 'appDebug' })}
<Trans
i18nKey="variableConfig.hiddenDescription"
ns="appDebug"
components={{
docLink: (
<a
href={docLink('/use-dify/nodes/user-input')}
target="_blank"
rel="noopener noreferrer"
className="text-text-accent hover:underline"
/>
),
}}
/>
</TooltipContent>
</Tooltip>
</div>

View File

@@ -326,7 +326,7 @@
"variableConfig.file.supportFileTypes": "Support File Types",
"variableConfig.file.video.name": "Video",
"variableConfig.hidden": "Hidden",
"variableConfig.hiddenDescription": "Hidden fields are not shown in the Web App start form and can be filled through URL query parameters.",
"variableConfig.hiddenDescription": "Hidden fields are not shown in the Web App start form. They can be populated via URL query parameters. For more details, <docLink>view the documentation</docLink>.",
"variableConfig.hide": "Hide",
"variableConfig.inputPlaceholder": "Please input",
"variableConfig.json": "JSON Code",

View File

@@ -326,7 +326,7 @@
"variableConfig.file.supportFileTypes": "支持的文件类型",
"variableConfig.file.video.name": "视频",
"variableConfig.hidden": "Hidden",
"variableConfig.hiddenDescription": "隐藏字段不会显示在 Web App 的开始表单中,可通过 URL 查询参数传值。",
"variableConfig.hiddenDescription": "隐藏字段不会显示在 Web App 的开始表单中,可通过 URL 查询参数传值。更多信息查看<docLink>文档</docLink>。",
"variableConfig.hide": "隐藏",
"variableConfig.inputPlaceholder": "请输入",
"variableConfig.json": "JSON",