mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 09:28:04 +08:00
chore: fix type check for i18n (#30058)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
@ -94,7 +94,7 @@ const BlockInput: FC<IBlockInputProps> = ({
|
||||
if (!isValid) {
|
||||
Toast.notify({
|
||||
type: 'error',
|
||||
message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
|
||||
message: t(`appDebug.varKeyError.${errorMessageKey}` as any, { key: errorKey }) as string,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import type {
|
||||
ChatItem,
|
||||
Feedback,
|
||||
} from '../types'
|
||||
import type { Locale } from '@/i18n-config'
|
||||
import type {
|
||||
// AppData,
|
||||
ConversationItem,
|
||||
@ -93,7 +94,7 @@ export const useEmbeddedChatbot = () => {
|
||||
|
||||
if (localeParam) {
|
||||
// If locale parameter exists in URL, use it instead of default
|
||||
await changeLanguage(localeParam)
|
||||
await changeLanguage(localeParam as Locale)
|
||||
}
|
||||
else if (localeFromSysVar) {
|
||||
// If locale is set as a system variable, use that
|
||||
|
||||
@ -6,7 +6,7 @@ const YEAR_RANGE = 100
|
||||
|
||||
export const useDaysOfWeek = () => {
|
||||
const { t } = useTranslation()
|
||||
const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(day => t(`time.daysInWeek.${day}`))
|
||||
const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(day => t(`time.daysInWeek.${day}` as any) as string)
|
||||
|
||||
return daysOfWeek
|
||||
}
|
||||
@ -26,7 +26,7 @@ export const useMonths = () => {
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
].map(month => t(`time.months.${month}`))
|
||||
].map(month => t(`time.months.${month}` as any) as string)
|
||||
|
||||
return months
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ export const EncryptedBottom = (props: Props) => {
|
||||
return (
|
||||
<div className={cn('system-xs-regular flex items-center justify-center rounded-b-2xl border-t-[0.5px] border-divider-subtle bg-background-soft px-2 py-3 text-text-tertiary', className)}>
|
||||
<RiLock2Fill className="mx-1 h-3 w-3 text-text-quaternary" />
|
||||
{t(frontTextKey || 'common.provider.encrypted.front')}
|
||||
{t((frontTextKey || 'common.provider.encrypted.front') as any) as string}
|
||||
<Link
|
||||
className="mx-1 text-text-accent"
|
||||
target="_blank"
|
||||
@ -25,7 +25,7 @@ export const EncryptedBottom = (props: Props) => {
|
||||
>
|
||||
PKCS1_OAEP
|
||||
</Link>
|
||||
{t(backTextKey || 'common.provider.encrypted.back')}
|
||||
{t((backTextKey || 'common.provider.encrypted.back') as any) as string}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ const VoiceParamConfig = ({
|
||||
className="h-full w-full cursor-pointer rounded-lg border-0 bg-components-input-bg-normal py-1.5 pl-3 pr-10 focus-visible:bg-state-base-hover focus-visible:outline-none group-hover:bg-state-base-hover sm:text-sm sm:leading-6"
|
||||
>
|
||||
<span className={cn('block truncate text-left text-text-secondary', !languageItem?.name && 'text-text-tertiary')}>
|
||||
{languageItem?.name ? t(`common.voice.language.${languageItem?.value.replace('-', '')}`) : localLanguagePlaceholder}
|
||||
{languageItem?.name ? t(`common.voice.language.${languageItem?.value.replace('-', '')}` as any) as string : localLanguagePlaceholder}
|
||||
</span>
|
||||
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<ChevronDownIcon
|
||||
@ -128,7 +128,7 @@ const VoiceParamConfig = ({
|
||||
<span
|
||||
className={cn('block', selected && 'font-normal')}
|
||||
>
|
||||
{t(`common.voice.language.${(item.value).toString().replace('-', '')}`)}
|
||||
{t(`common.voice.language.${(item.value).toString().replace('-', '')}` as any) as string}
|
||||
</span>
|
||||
{(selected || item.value === text2speech?.language) && (
|
||||
<span
|
||||
|
||||
@ -174,7 +174,7 @@ export const useFile = (fileConfig: FileUpload, noNeedToCheckEnable = true) => {
|
||||
handleUpdateFile({ ...uploadingFile, uploadedId: res.id, progress: 100 })
|
||||
},
|
||||
onErrorCallback: (error?: any) => {
|
||||
const errorMessage = getFileUploadErrorMessage(error, t('common.fileUploader.uploadFromComputerUploadError'), t)
|
||||
const errorMessage = getFileUploadErrorMessage(error, t('common.fileUploader.uploadFromComputerUploadError'), t as any)
|
||||
notify({ type: 'error', message: errorMessage })
|
||||
handleUpdateFile({ ...uploadingFile, progress: -1 })
|
||||
},
|
||||
@ -287,7 +287,7 @@ export const useFile = (fileConfig: FileUpload, noNeedToCheckEnable = true) => {
|
||||
handleUpdateFile({ ...uploadingFile, uploadedId: res.id, progress: 100 })
|
||||
},
|
||||
onErrorCallback: (error?: any) => {
|
||||
const errorMessage = getFileUploadErrorMessage(error, t('common.fileUploader.uploadFromComputerUploadError'), t)
|
||||
const errorMessage = getFileUploadErrorMessage(error, t('common.fileUploader.uploadFromComputerUploadError'), t as any)
|
||||
notify({ type: 'error', message: errorMessage })
|
||||
handleUpdateFile({ ...uploadingFile, progress: -1 })
|
||||
},
|
||||
|
||||
@ -44,7 +44,7 @@ export const useInputTypeOptions = (supportFile: boolean) => {
|
||||
return options.map((value) => {
|
||||
return {
|
||||
value,
|
||||
label: t(`appDebug.variableConfig.${i18nFileTypeMap[value] || value}`),
|
||||
label: t(`appDebug.variableConfig.${i18nFileTypeMap[value] || value}` as any),
|
||||
Icon: INPUT_TYPE_ICON[value],
|
||||
type: DATA_TYPE[value],
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ export const useImageFiles = () => {
|
||||
setFiles(newFiles)
|
||||
},
|
||||
onErrorCallback: (error?: any) => {
|
||||
const errorMessage = getImageUploadErrorMessage(error, t('common.imageUploader.uploadFromComputerUploadError'), t)
|
||||
const errorMessage = getImageUploadErrorMessage(error, t('common.imageUploader.uploadFromComputerUploadError'), t as any)
|
||||
notify({ type: 'error', message: errorMessage })
|
||||
const newFiles = [...files.slice(0, index), { ...currentImageFile, progress: -1 }, ...files.slice(index + 1)]
|
||||
filesRef.current = newFiles
|
||||
@ -160,7 +160,7 @@ export const useLocalFileUploader = ({ limit, disabled = false, onUpload }: useL
|
||||
onUpload({ ...imageFile, fileId: res.id, progress: 100 })
|
||||
},
|
||||
onErrorCallback: (error?: any) => {
|
||||
const errorMessage = getImageUploadErrorMessage(error, t('common.imageUploader.uploadFromComputerUploadError'), t)
|
||||
const errorMessage = getImageUploadErrorMessage(error, t('common.imageUploader.uploadFromComputerUploadError'), t as any)
|
||||
notify({ type: 'error', message: errorMessage })
|
||||
onUpload({ ...imageFile, progress: -1 })
|
||||
},
|
||||
|
||||
@ -127,7 +127,7 @@ const TagInput: FC<TagInputProps> = ({
|
||||
setValue(e.target.value)
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder={t(placeholder || (isSpecialMode ? 'common.model.params.stop_sequencesPlaceholder' : 'datasetDocuments.segment.addKeyWord'))}
|
||||
placeholder={t((placeholder || (isSpecialMode ? 'common.model.params.stop_sequencesPlaceholder' : 'datasetDocuments.segment.addKeyWord')) as any)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user