mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 11:04:27 +08:00
chore: tip i18n
This commit is contained in:
parent
27791ac121
commit
12b2f0ac3b
@ -4,6 +4,29 @@ import { fireEvent, render, screen } from '@testing-library/react'
|
|||||||
import { InputVarType } from '@/app/components/workflow/types'
|
import { InputVarType } from '@/app/components/workflow/types'
|
||||||
import ConfigModalFormFields from '../form-fields'
|
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', () => ({
|
vi.mock('@/app/components/base/file-uploader', () => ({
|
||||||
FileUploaderInAttachmentWrapper: ({ onChange }: { onChange: (files: Array<Record<string, unknown>>) => void }) => (
|
FileUploaderInAttachmentWrapper: ({ onChange }: { onChange: (files: Array<Record<string, unknown>>) => void }) => (
|
||||||
<button
|
<button
|
||||||
@ -170,6 +193,9 @@ describe('ConfigModalFormFields', () => {
|
|||||||
const textInputView = render(<ConfigModalFormFields {...textInputProps} />)
|
const textInputView = render(<ConfigModalFormFields {...textInputProps} />)
|
||||||
expect(screen.getByText('variableConfig.hidden')).toBeInTheDocument()
|
expect(screen.getByText('variableConfig.hidden')).toBeInTheDocument()
|
||||||
expect(screen.getByText('variableConfig.hiddenDescription')).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()
|
textInputView.unmount()
|
||||||
|
|
||||||
const singleFileProps = createBaseProps()
|
const singleFileProps = createBaseProps()
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
|||||||
import type { InputVar, UploadFileSetting } from '@/app/components/workflow/types'
|
import type { InputVar, UploadFileSetting } from '@/app/components/workflow/types'
|
||||||
import { RiQuestionLine } from '@remixicon/react'
|
import { RiQuestionLine } from '@remixicon/react'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
import { Trans } from 'react-i18next'
|
||||||
import Checkbox from '@/app/components/base/checkbox'
|
import Checkbox from '@/app/components/base/checkbox'
|
||||||
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
|
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
|
||||||
import Input from '@/app/components/base/input'
|
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 FileUploadSetting from '@/app/components/workflow/nodes/_base/components/file-upload-setting'
|
||||||
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||||
import { InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types'
|
import { InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||||
|
import { useDocLink } from '@/context/i18n'
|
||||||
import { TransferMethod } from '@/types/app'
|
import { TransferMethod } from '@/types/app'
|
||||||
import ConfigSelect from '../config-select'
|
import ConfigSelect from '../config-select'
|
||||||
import ConfigString from '../config-string'
|
import ConfigString from '../config-string'
|
||||||
@ -69,6 +71,7 @@ const ConfigModalFormFields: FC<ConfigModalFormFieldsProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { type, label, variable } = tempPayload
|
const { type, label, variable } = tempPayload
|
||||||
const isFileInput = [InputVarType.singleFile, InputVarType.multiFiles].includes(type)
|
const isFileInput = [InputVarType.singleFile, InputVarType.multiFiles].includes(type)
|
||||||
|
const docLink = useDocLink()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@ -232,7 +235,20 @@ const ConfigModalFormFields: FC<ConfigModalFormFieldsProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<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>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -326,7 +326,7 @@
|
|||||||
"variableConfig.file.supportFileTypes": "Support File Types",
|
"variableConfig.file.supportFileTypes": "Support File Types",
|
||||||
"variableConfig.file.video.name": "Video",
|
"variableConfig.file.video.name": "Video",
|
||||||
"variableConfig.hidden": "Hidden",
|
"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.hide": "Hide",
|
||||||
"variableConfig.inputPlaceholder": "Please input",
|
"variableConfig.inputPlaceholder": "Please input",
|
||||||
"variableConfig.json": "JSON Code",
|
"variableConfig.json": "JSON Code",
|
||||||
|
|||||||
@ -326,7 +326,7 @@
|
|||||||
"variableConfig.file.supportFileTypes": "支持的文件类型",
|
"variableConfig.file.supportFileTypes": "支持的文件类型",
|
||||||
"variableConfig.file.video.name": "视频",
|
"variableConfig.file.video.name": "视频",
|
||||||
"variableConfig.hidden": "Hidden",
|
"variableConfig.hidden": "Hidden",
|
||||||
"variableConfig.hiddenDescription": "隐藏字段不会显示在 Web App 的开始表单中,可通过 URL 查询参数传值。",
|
"variableConfig.hiddenDescription": "隐藏字段不会显示在 Web App 的开始表单中,可通过 URL 查询参数传值。更多信息查看<docLink>文档</docLink>。",
|
||||||
"variableConfig.hide": "隐藏",
|
"variableConfig.hide": "隐藏",
|
||||||
"variableConfig.inputPlaceholder": "请输入",
|
"variableConfig.inputPlaceholder": "请输入",
|
||||||
"variableConfig.json": "JSON",
|
"variableConfig.json": "JSON",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user