mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-24 18:23:07 +08:00
Feat/i18n restructure (#2529)
This commit is contained in:
@@ -5,7 +5,7 @@ import TemplateZh from './template/template.zh.mdx'
|
||||
import TemplateChatEn from './template/template_chat.en.mdx'
|
||||
import TemplateChatZh from './template/template_chat.zh.mdx'
|
||||
import I18n from '@/context/i18n'
|
||||
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
|
||||
type IDocProps = {
|
||||
appDetail: any
|
||||
@@ -13,7 +13,7 @@ type IDocProps = {
|
||||
|
||||
const Doc = ({ appDetail }: IDocProps) => {
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
|
||||
const variables = appDetail?.model_config?.configs?.prompt_variables || []
|
||||
const inputs = variables.reduce((res: any, variable: any) => {
|
||||
res[variable.key] = variable.name || ''
|
||||
@@ -24,10 +24,10 @@ const Doc = ({ appDetail }: IDocProps) => {
|
||||
<article className="prose prose-xl" >
|
||||
{appDetail?.mode === 'completion'
|
||||
? (
|
||||
language !== LanguagesSupportedUnderscore[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
|
||||
locale !== LanguagesSupported[1] ? <TemplateEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateZh appDetail={appDetail} variables={variables} inputs={inputs} />
|
||||
)
|
||||
: (
|
||||
language !== LanguagesSupportedUnderscore[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
|
||||
locale !== LanguagesSupported[1] ? <TemplateChatEn appDetail={appDetail} variables={variables} inputs={inputs} /> : <TemplateChatZh appDetail={appDetail} variables={variables} inputs={inputs} />
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ import Tooltip from '@/app/components/base/tooltip'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import Confirm from '@/app/components/base/confirm'
|
||||
import I18n from '@/context/i18n'
|
||||
import { LanguagesSupported, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
|
||||
type ISecretKeyModalProps = {
|
||||
@@ -56,7 +56,6 @@ const SecretKeyModal = ({
|
||||
const [delKeyID, setDelKeyId] = useState('')
|
||||
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
|
||||
// const [isCopied, setIsCopied] = useState(false)
|
||||
const [copyValue, setCopyValue] = useState('')
|
||||
@@ -102,7 +101,7 @@ const SecretKeyModal = ({
|
||||
}
|
||||
|
||||
const formatDate = (timestamp: string) => {
|
||||
if (language === LanguagesSupported[0])
|
||||
if (locale === LanguagesSupported[0])
|
||||
return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' }).format((+timestamp) * 1000)
|
||||
else
|
||||
return new Intl.DateTimeFormat('fr-CA', { year: 'numeric', month: '2-digit', day: '2-digit' }).format((+timestamp) * 1000)
|
||||
|
||||
Reference in New Issue
Block a user