= (props) => {
({
- name: t(STEP_T_MAP[i + 1] as any) as string,
+ name: t(STEP_T_MAP[(i + 1) as keyof typeof STEP_T_MAP], { ns: 'datasetCreation' }),
}))}
{...rest}
/>
diff --git a/web/app/components/datasets/documents/detail/completed/index.tsx b/web/app/components/datasets/documents/detail/completed/index.tsx
index e27fa9cabb..531603a1cf 100644
--- a/web/app/components/datasets/documents/detail/completed/index.tsx
+++ b/web/app/components/datasets/documents/detail/completed/index.tsx
@@ -427,9 +427,9 @@ const Completed: FC = ({
const total = segmentListData?.total ? formatNumber(segmentListData.total) : '--'
const count = total === '--' ? 0 : segmentListData!.total
const translationKey = (docForm === ChunkingMode.parentChild && parentMode === 'paragraph')
- ? 'datasetDocuments.segment.parentChunks'
- : 'datasetDocuments.segment.chunks'
- return `${total} ${t(translationKey, { count })}`
+ ? 'segment.parentChunks' as const
+ : 'segment.chunks' as const
+ return `${total} ${t(translationKey, { ns: 'datasetDocuments', count })}`
}
else {
const total = typeof segmentListData?.total === 'number' ? formatNumber(segmentListData.total) : 0
diff --git a/web/app/components/explore/category.tsx b/web/app/components/explore/category.tsx
index 0e507b457f..57728def27 100644
--- a/web/app/components/explore/category.tsx
+++ b/web/app/components/explore/category.tsx
@@ -7,8 +7,6 @@ import { ThumbsUp } from '@/app/components/base/icons/src/vender/line/alertsAndF
import exploreI18n from '@/i18n/en-US/explore.json'
import { cn } from '@/utils/classnames'
-const categoryI18n = exploreI18n.category
-
export type ICategoryProps = {
className?: string
list: AppCategory[]
@@ -50,7 +48,7 @@ const Category: FC = ({
className={itemClassName(name === value)}
onClick={() => onChange(name)}
>
- {(categoryI18n as any)[name] ? t(`category.${name}` as any, { ns: 'explore' }) as string : name}
+ {`category.${name}` in exploreI18n ? t(`category.${name}` as any, { ns: 'explore' }) as string : name}
))}
diff --git a/web/app/components/goto-anything/actions/commands/theme.tsx b/web/app/components/goto-anything/actions/commands/theme.tsx
index 34df84e33b..335182af67 100644
--- a/web/app/components/goto-anything/actions/commands/theme.tsx
+++ b/web/app/components/goto-anything/actions/commands/theme.tsx
@@ -1,4 +1,3 @@
-import type { ReactNode } from 'react'
import type { CommandSearchResult } from '../types'
import type { SlashCommandHandler } from './types'
import { RiComputerLine, RiMoonLine, RiSunLine } from '@remixicon/react'
@@ -11,38 +10,38 @@ type ThemeDeps = {
setTheme?: (value: 'light' | 'dark' | 'system') => void
}
-const THEME_ITEMS: { id: 'light' | 'dark' | 'system', titleKey: string, descKey: string, icon: ReactNode }[] = [
+const THEME_ITEMS = [
{
id: 'system',
- titleKey: 'app.gotoAnything.actions.themeSystem',
- descKey: 'app.gotoAnything.actions.themeSystemDesc',
+ titleKey: 'gotoAnything.actions.themeSystem',
+ descKey: 'gotoAnything.actions.themeSystemDesc',
icon: ,
},
{
id: 'light',
- titleKey: 'app.gotoAnything.actions.themeLight',
- descKey: 'app.gotoAnything.actions.themeLightDesc',
+ titleKey: 'gotoAnything.actions.themeLight',
+ descKey: 'gotoAnything.actions.themeLightDesc',
icon: ,
},
{
id: 'dark',
- titleKey: 'app.gotoAnything.actions.themeDark',
- descKey: 'app.gotoAnything.actions.themeDarkDesc',
+ titleKey: 'gotoAnything.actions.themeDark',
+ descKey: 'gotoAnything.actions.themeDarkDesc',
icon: ,
},
-]
+] as const
const buildThemeCommands = (query: string, locale?: string): CommandSearchResult[] => {
const q = query.toLowerCase()
const list = THEME_ITEMS.filter(item =>
!q
- || i18n.t(item.titleKey as any, { lng: locale }).toLowerCase().includes(q)
+ || i18n.t(item.titleKey, { ns: 'app', lng: locale }).toLowerCase().includes(q)
|| item.id.includes(q),
)
return list.map(item => ({
id: item.id,
- title: i18n.t(item.titleKey as any, { lng: locale }),
- description: i18n.t(item.descKey as any, { lng: locale }),
+ title: i18n.t(item.titleKey, { ns: 'app', lng: locale }),
+ description: i18n.t(item.descKey, { ns: 'app', lng: locale }),
type: 'command' as const,
icon: (
diff --git a/web/app/components/goto-anything/command-selector.tsx b/web/app/components/goto-anything/command-selector.tsx
index a5593d2a6f..bdb641cae6 100644
--- a/web/app/components/goto-anything/command-selector.tsx
+++ b/web/app/components/goto-anything/command-selector.tsx
@@ -108,27 +108,27 @@ const CommandSelector: FC
= ({ actions, onCommandSelect, searchFilter, co
{isSlashMode
? (
(() => {
- const slashKeyMap: Record = {
- '/theme': 'app.gotoAnything.actions.themeCategoryDesc',
- '/language': 'app.gotoAnything.actions.languageChangeDesc',
- '/account': 'app.gotoAnything.actions.accountDesc',
- '/feedback': 'app.gotoAnything.actions.feedbackDesc',
- '/docs': 'app.gotoAnything.actions.docDesc',
- '/community': 'app.gotoAnything.actions.communityDesc',
- '/zen': 'app.gotoAnything.actions.zenDesc',
- }
- return t((slashKeyMap[item.key] || item.description) as any)
+ const slashKeyMap = {
+ '/theme': 'gotoAnything.actions.themeCategoryDesc',
+ '/language': 'gotoAnything.actions.languageChangeDesc',
+ '/account': 'gotoAnything.actions.accountDesc',
+ '/feedback': 'gotoAnything.actions.feedbackDesc',
+ '/docs': 'gotoAnything.actions.docDesc',
+ '/community': 'gotoAnything.actions.communityDesc',
+ '/zen': 'gotoAnything.actions.zenDesc',
+ } as const
+ return t(slashKeyMap[item.key as keyof typeof slashKeyMap] || item.description, { ns: 'app' })
})()
)
: (
(() => {
- const keyMap: Record = {
- '@app': 'app.gotoAnything.actions.searchApplicationsDesc',
- '@plugin': 'app.gotoAnything.actions.searchPluginsDesc',
- '@knowledge': 'app.gotoAnything.actions.searchKnowledgeBasesDesc',
- '@node': 'app.gotoAnything.actions.searchWorkflowNodesDesc',
- }
- return t(keyMap[item.key] as any) as string
+ const keyMap = {
+ '@app': 'gotoAnything.actions.searchApplicationsDesc',
+ '@plugin': 'gotoAnything.actions.searchPluginsDesc',
+ '@knowledge': 'gotoAnything.actions.searchKnowledgeBasesDesc',
+ '@node': 'gotoAnything.actions.searchWorkflowNodesDesc',
+ } as const
+ return t(keyMap[item.key as keyof typeof keyMap], { ns: 'app' })
})()
)}
diff --git a/web/app/components/goto-anything/index.tsx b/web/app/components/goto-anything/index.tsx
index b24e858c25..30add3480d 100644
--- a/web/app/components/goto-anything/index.tsx
+++ b/web/app/components/goto-anything/index.tsx
@@ -237,13 +237,13 @@ const GotoAnything: FC = ({
{isCommandSearch
? (() => {
- const keyMap: Record = {
- app: 'app.gotoAnything.emptyState.noAppsFound',
- plugin: 'app.gotoAnything.emptyState.noPluginsFound',
- knowledge: 'app.gotoAnything.emptyState.noKnowledgeBasesFound',
- node: 'app.gotoAnything.emptyState.noWorkflowNodesFound',
- }
- return t((keyMap[commandType] || 'app.gotoAnything.noResults') as any)
+ const keyMap = {
+ app: 'gotoAnything.emptyState.noAppsFound',
+ plugin: 'gotoAnything.emptyState.noPluginsFound',
+ knowledge: 'gotoAnything.emptyState.noKnowledgeBasesFound',
+ node: 'gotoAnything.emptyState.noWorkflowNodesFound',
+ } as const
+ return t(keyMap[commandType as keyof typeof keyMap] || 'gotoAnything.noResults', { ns: 'app' })
})()
: t('gotoAnything.noResults', { ns: 'app' })}
@@ -403,14 +403,14 @@ const GotoAnything: FC = ({
{
- const typeMap: Record = {
- 'app': 'app.gotoAnything.groups.apps',
- 'plugin': 'app.gotoAnything.groups.plugins',
- 'knowledge': 'app.gotoAnything.groups.knowledgeBases',
- 'workflow-node': 'app.gotoAnything.groups.workflowNodes',
- 'command': 'app.gotoAnything.groups.commands',
- }
- return t((typeMap[type] || `${type}s`) as any)
+ const typeMap = {
+ 'app': 'gotoAnything.groups.apps',
+ 'plugin': 'gotoAnything.groups.plugins',
+ 'knowledge': 'gotoAnything.groups.knowledgeBases',
+ 'workflow-node': 'gotoAnything.groups.workflowNodes',
+ 'command': 'gotoAnything.groups.commands',
+ } as const
+ return t(typeMap[type as keyof typeof typeMap] || `${type}s`, { ns: 'app' })
})()}
className="p-2 capitalize text-text-secondary"
>
diff --git a/web/app/components/plugins/marketplace/description/index.tsx b/web/app/components/plugins/marketplace/description/index.tsx
index 66a6368c08..9a0850d127 100644
--- a/web/app/components/plugins/marketplace/description/index.tsx
+++ b/web/app/components/plugins/marketplace/description/index.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable dify-i18n/require-ns-option */
import type { Locale } from '@/i18n-config'
import {
getLocaleOnServer,
diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
index c682f21504..91a844fb86 100644
--- a/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/create/common-modal.tsx
@@ -42,11 +42,11 @@ const CREDENTIAL_TYPE_MAP: Record = {
- [SupportedCreationMethods.APIKEY]: 'pluginTrigger.modal.apiKey.title',
- [SupportedCreationMethods.OAUTH]: 'pluginTrigger.modal.oauth.title',
- [SupportedCreationMethods.MANUAL]: 'pluginTrigger.modal.manual.title',
+ [SupportedCreationMethods.APIKEY]: 'modal.apiKey.title',
+ [SupportedCreationMethods.OAUTH]: 'modal.oauth.title',
+ [SupportedCreationMethods.MANUAL]: 'modal.manual.title',
}
enum ApiKeyStep {
@@ -347,7 +347,7 @@ export const CommonCreateModal = ({ onClose, createType, builder }: Props) => {
return (
= ({
const newList = produce(list, (draft) => {
draft[index] = payload
})
- let errorMsgKey = ''
- let typeName = ''
+ let errorMsgKey: 'varKeyError.keyAlreadyExists' | '' = ''
+ let typeName: 'variableConfig.varName' | 'variableConfig.labelName' | '' = ''
if (hasDuplicateStr(newList.map(item => item.variable))) {
- errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
- typeName = 'appDebug.variableConfig.varName'
+ errorMsgKey = 'varKeyError.keyAlreadyExists'
+ typeName = 'variableConfig.varName'
}
else if (hasDuplicateStr(newList.map(item => item.label as string))) {
- errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
- typeName = 'appDebug.variableConfig.labelName'
+ errorMsgKey = 'varKeyError.keyAlreadyExists'
+ typeName = 'variableConfig.labelName'
}
- if (errorMsgKey) {
+ if (errorMsgKey && typeName) {
Toast.notify({
type: 'error',
- message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
+ message: t(errorMsgKey, { ns: 'appDebug', key: t(typeName, { ns: 'appDebug' }) }),
})
return false
}
diff --git a/web/app/components/workflow/nodes/start/use-config.ts b/web/app/components/workflow/nodes/start/use-config.ts
index e563e710ce..232c788b6d 100644
--- a/web/app/components/workflow/nodes/start/use-config.ts
+++ b/web/app/components/workflow/nodes/start/use-config.ts
@@ -85,21 +85,21 @@ const useConfig = (id: string, payload: StartNodeType) => {
draft.variables.push(payload)
})
const newList = newInputs.variables
- let errorMsgKey = ''
- let typeName = ''
+ let errorMsgKey: 'varKeyError.keyAlreadyExists' | '' = ''
+ let typeName: 'variableConfig.varName' | 'variableConfig.labelName' | '' = ''
if (hasDuplicateStr(newList.map(item => item.variable))) {
- errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
- typeName = 'appDebug.variableConfig.varName'
+ errorMsgKey = 'varKeyError.keyAlreadyExists'
+ typeName = 'variableConfig.varName'
}
else if (hasDuplicateStr(newList.map(item => item.label as string))) {
- errorMsgKey = 'appDebug.varKeyError.keyAlreadyExists'
- typeName = 'appDebug.variableConfig.labelName'
+ errorMsgKey = 'varKeyError.keyAlreadyExists'
+ typeName = 'variableConfig.labelName'
}
- if (errorMsgKey) {
+ if (errorMsgKey && typeName) {
Toast.notify({
type: 'error',
- message: t(errorMsgKey as any, { key: t(typeName as any) as string }) as string,
+ message: t(errorMsgKey, { ns: 'appDebug', key: t(typeName, { ns: 'appDebug' }) }),
})
return false
}
diff --git a/web/app/components/workflow/nodes/variable-assigner/default.ts b/web/app/components/workflow/nodes/variable-assigner/default.ts
index 7ee1736570..800fb74e36 100644
--- a/web/app/components/workflow/nodes/variable-assigner/default.ts
+++ b/web/app/components/workflow/nodes/variable-assigner/default.ts
@@ -5,8 +5,6 @@ import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
import { VarType } from '../../types'
-const i18nPrefix = ''
-
const metaData = genNodeMetaData({
classification: BlockClassificationEnum.Transform,
sort: 3,
@@ -23,28 +21,28 @@ const nodeDefault: NodeDefault = {
const { variables, advanced_settings } = payload
const { group_enabled = false, groups = [] } = advanced_settings || {}
// enable group
- const validateVariables = (variables: any[], field: string) => {
+ const validateVariables = (variables: any[], field: 'errorMsg.fields.variableValue') => {
variables.forEach((variable) => {
if (!variable || variable.length === 0)
- errorMessages = t(`${i18nPrefix}errorMsg.fieldRequired`, { ns: 'workflow', field: t(field) })
+ errorMessages = t('errorMsg.fieldRequired', { ns: 'workflow', field: t(field, { ns: 'workflow' }) })
})
}
if (group_enabled) {
if (!groups || groups.length === 0) {
- errorMessages = t(`${i18nPrefix}errorMsg.fieldRequired`, { ns: 'workflow', field: t(`${i18nPrefix}nodes.variableAssigner.title`, { ns: 'workflow' }) })
+ errorMessages = t('errorMsg.fieldRequired', { ns: 'workflow', field: t('nodes.variableAssigner.title', { ns: 'workflow' }) })
}
else if (!errorMessages) {
groups.forEach((group) => {
- validateVariables(group.variables || [], `${i18nPrefix}.errorMsg.fields.variableValue`)
+ validateVariables(group.variables || [], 'errorMsg.fields.variableValue')
})
}
}
else {
if (!variables || variables.length === 0)
- errorMessages = t(`${i18nPrefix}errorMsg.fieldRequired`, { ns: 'workflow', field: t(`${i18nPrefix}nodes.variableAssigner.title`, { ns: 'workflow' }) })
+ errorMessages = t('errorMsg.fieldRequired', { ns: 'workflow', field: t('nodes.variableAssigner.title', { ns: 'workflow' }) })
else if (!errorMessages)
- validateVariables(variables, `${i18nPrefix}.errorMsg.fields.variableValue`)
+ validateVariables(variables, 'errorMsg.fields.variableValue')
}
return {
diff --git a/web/app/forgot-password/ForgotPasswordForm.tsx b/web/app/forgot-password/ForgotPasswordForm.tsx
index d41815dd52..0fc4fa9c5d 100644
--- a/web/app/forgot-password/ForgotPasswordForm.tsx
+++ b/web/app/forgot-password/ForgotPasswordForm.tsx
@@ -23,8 +23,8 @@ import Loading from '../components/base/loading'
const accountFormSchema = z.object({
email: z
.string()
- .min(1, { message: 'login.error.emailInValid' })
- .email('login.error.emailInValid'),
+ .min(1, { message: 'error.emailInValid' })
+ .email('error.emailInValid'),
})
type AccountFormValues = z.infer
@@ -108,7 +108,7 @@ const ForgotPasswordForm = () => {
{...register('email')}
placeholder={t('emailPlaceholder', { ns: 'login' }) || ''}
/>
- {errors.email && {t(`${errors.email?.message}` as any) as string}}
+ {errors.email && {t(`${errors.email?.message}` as any, { ns: 'login' })}}
)}
diff --git a/web/app/install/installForm.tsx b/web/app/install/installForm.tsx
index bfd0549abe..29f419e8d0 100644
--- a/web/app/install/installForm.tsx
+++ b/web/app/install/installForm.tsx
@@ -24,12 +24,12 @@ import Loading from '../components/base/loading'
const accountFormSchema = z.object({
email: z
.string()
- .min(1, { message: 'login.error.emailInValid' })
- .email('login.error.emailInValid'),
- name: z.string().min(1, { message: 'login.error.nameEmpty' }),
+ .min(1, { message: 'error.emailInValid' })
+ .email('error.emailInValid'),
+ name: z.string().min(1, { message: 'error.nameEmpty' }),
password: z.string().min(8, {
- message: 'login.error.passwordLengthInValid',
- }).regex(validPassword, 'login.error.passwordInvalid'),
+ message: 'error.passwordLengthInValid',
+ }).regex(validPassword, 'error.passwordInvalid'),
})
type AccountFormValues = z.infer
@@ -138,7 +138,7 @@ const InstallForm = () => {
placeholder={t('emailPlaceholder', { ns: 'login' }) || ''}
className="system-sm-regular w-full appearance-none rounded-md border border-transparent bg-components-input-bg-normal px-3 py-[7px] text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs"
/>
- {errors.email && {t(`${errors.email?.message}` as any) as string}}
+ {errors.email && {t(`${errors.email?.message}` as any, { ns: 'login' })}}
@@ -154,7 +154,7 @@ const InstallForm = () => {
className="system-sm-regular w-full appearance-none rounded-md border border-transparent bg-components-input-bg-normal px-3 py-[7px] text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs"
/>
- {errors.name && {t(`${errors.name.message}` as any) as string}}
+ {errors.name && {t(`${errors.name.message}` as any, { ns: 'login' })}}