mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
refactor(i18n): use JSON with flattened key and namespace (#30114)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -50,37 +50,37 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {
|
||||
|
||||
return (
|
||||
<div className="mt-6">
|
||||
<div className="text-sm font-medium text-text-primary">{t('share.generation.csvStructureTitle')}</div>
|
||||
<div className="text-sm font-medium text-text-primary">{t('generation.csvStructureTitle', { ns: 'share' })}</div>
|
||||
<div className="mt-2 max-h-[500px] overflow-auto">
|
||||
{docForm === ChunkingMode.qa && (
|
||||
<table className="w-full table-fixed border-separate border-spacing-0 rounded-lg border border-divider-subtle text-xs">
|
||||
<thead className="text-text-secondary">
|
||||
<tr>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('datasetDocuments.list.batchModal.question')}</td>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('datasetDocuments.list.batchModal.answer')}</td>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('list.batchModal.question', { ns: 'datasetDocuments' })}</td>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('list.batchModal.answer', { ns: 'datasetDocuments' })}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-text-tertiary">
|
||||
<tr>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.question')}
|
||||
{t('list.batchModal.question', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
1
|
||||
</td>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.answer')}
|
||||
{t('list.batchModal.answer', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
1
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="h-9 pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.question')}
|
||||
{t('list.batchModal.question', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
2
|
||||
</td>
|
||||
<td className="h-9 pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.answer')}
|
||||
{t('list.batchModal.answer', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
2
|
||||
</td>
|
||||
@ -92,20 +92,20 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {
|
||||
<table className="w-full table-fixed border-separate border-spacing-0 rounded-lg border border-divider-subtle text-xs">
|
||||
<thead className="text-text-secondary">
|
||||
<tr>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('datasetDocuments.list.batchModal.contentTitle')}</td>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2">{t('list.batchModal.contentTitle', { ns: 'datasetDocuments' })}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-text-tertiary">
|
||||
<tr>
|
||||
<td className="h-9 border-b border-divider-subtle pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.content')}
|
||||
{t('list.batchModal.content', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
1
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="h-9 pl-3 pr-2 text-[13px]">
|
||||
{t('datasetDocuments.list.batchModal.content')}
|
||||
{t('list.batchModal.content', { ns: 'datasetDocuments' })}
|
||||
{' '}
|
||||
2
|
||||
</td>
|
||||
@ -123,7 +123,7 @@ const CSVDownload: FC<{ docForm: ChunkingMode }> = ({ docForm }) => {
|
||||
>
|
||||
<div className="flex h-[18px] items-center space-x-1 text-xs font-medium text-text-accent">
|
||||
<DownloadIcon className="mr-1 h-3 w-3" />
|
||||
{t('datasetDocuments.list.batchModal.template')}
|
||||
{t('list.batchModal.template', { ns: 'datasetDocuments' })}
|
||||
</div>
|
||||
</CSVDownloader>
|
||||
</div>
|
||||
|
||||
@ -75,7 +75,7 @@ const CSVUploader: FC<Props> = ({
|
||||
return Promise.resolve({ ...completeFile })
|
||||
})
|
||||
.catch((e) => {
|
||||
const errorMessage = getFileUploadErrorMessage(e, t('datasetCreation.stepOne.uploader.failed'), t as any)
|
||||
const errorMessage = getFileUploadErrorMessage(e, t('stepOne.uploader.failed', { ns: 'datasetCreation' }), t)
|
||||
notify({ type: 'error', message: errorMessage })
|
||||
const errorFile = {
|
||||
...fileItem,
|
||||
@ -128,7 +128,7 @@ const CSVUploader: FC<Props> = ({
|
||||
return
|
||||
const files = [...e.dataTransfer.files]
|
||||
if (files.length > 1) {
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.count') })
|
||||
notify({ type: 'error', message: t('stepOne.uploader.validation.count', { ns: 'datasetCreation' }) })
|
||||
return
|
||||
}
|
||||
initialUpload(files[0])
|
||||
@ -159,11 +159,11 @@ const CSVUploader: FC<Props> = ({
|
||||
const ext = `.${getFileType(file)}`
|
||||
const isValidType = ext.toLowerCase() === '.csv'
|
||||
if (!isValidType)
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.typeError') })
|
||||
notify({ type: 'error', message: t('stepOne.uploader.validation.typeError', { ns: 'datasetCreation' }) })
|
||||
|
||||
const isValidSize = size <= fileUploadConfig.file_size_limit * 1024 * 1024
|
||||
if (!isValidSize)
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.size', { size: fileUploadConfig.file_size_limit }) })
|
||||
notify({ type: 'error', message: t('stepOne.uploader.validation.size', { ns: 'datasetCreation', size: fileUploadConfig.file_size_limit }) })
|
||||
|
||||
return isValidType && isValidSize
|
||||
}, [fileUploadConfig, notify, t])
|
||||
@ -208,8 +208,8 @@ const CSVUploader: FC<Props> = ({
|
||||
<div className="flex w-full items-center justify-center space-x-2">
|
||||
<CSVIcon className="shrink-0" />
|
||||
<div className="text-text-secondary">
|
||||
{t('datasetDocuments.list.batchModal.csvUploadTitle')}
|
||||
<span className="cursor-pointer text-text-accent" onClick={selectHandle}>{t('datasetDocuments.list.batchModal.browse')}</span>
|
||||
{t('list.batchModal.csvUploadTitle', { ns: 'datasetDocuments' })}
|
||||
<span className="cursor-pointer text-text-accent" onClick={selectHandle}>{t('list.batchModal.browse', { ns: 'datasetDocuments' })}</span>
|
||||
</div>
|
||||
</div>
|
||||
{dragging && <div ref={dragRef} className="absolute left-0 top-0 h-full w-full" />}
|
||||
@ -229,7 +229,7 @@ const CSVUploader: FC<Props> = ({
|
||||
<div className="mx-2 h-4 w-px bg-text-secondary" />
|
||||
</>
|
||||
)}
|
||||
<Button onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.change')}</Button>
|
||||
<Button onClick={selectHandle}>{t('stepOne.uploader.change', { ns: 'datasetCreation' })}</Button>
|
||||
<div className="mx-2 h-4 w-px bg-text-secondary" />
|
||||
<div className="cursor-pointer p-2" onClick={removeFile}>
|
||||
<RiDeleteBinLine className="h-4 w-4 text-text-secondary" />
|
||||
|
||||
@ -42,7 +42,7 @@ const BatchModal: FC<IBatchModalProps> = ({
|
||||
|
||||
return (
|
||||
<Modal isShow={isShow} onClose={noop} className="!max-w-[520px] !rounded-xl px-8 py-6">
|
||||
<div className="relative pb-1 text-xl font-medium leading-[30px] text-text-primary">{t('datasetDocuments.list.batchModal.title')}</div>
|
||||
<div className="relative pb-1 text-xl font-medium leading-[30px] text-text-primary">{t('list.batchModal.title', { ns: 'datasetDocuments' })}</div>
|
||||
<div className="absolute right-4 top-4 cursor-pointer p-2" onClick={onCancel}>
|
||||
<RiCloseLine className="h-4 w-4 text-text-secondary" />
|
||||
</div>
|
||||
@ -55,10 +55,10 @@ const BatchModal: FC<IBatchModalProps> = ({
|
||||
/>
|
||||
<div className="mt-[28px] flex justify-end pt-6">
|
||||
<Button className="mr-2" onClick={onCancel}>
|
||||
{t('datasetDocuments.list.batchModal.cancel')}
|
||||
{t('list.batchModal.cancel', { ns: 'datasetDocuments' })}
|
||||
</Button>
|
||||
<Button variant="primary" onClick={handleSend} disabled={!currentCSV || !currentCSV.file || !currentCSV.file.id}>
|
||||
{t('datasetDocuments.list.batchModal.run')}
|
||||
{t('list.batchModal.run', { ns: 'datasetDocuments' })}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user