mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 03:16:51 +08:00
Feat/i18n restructure (#2529)
This commit is contained in:
@@ -9,7 +9,7 @@ import { XClose } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import type { LangGeniusVersionResponse } from '@/models/common'
|
||||
import { IS_CE_EDITION } from '@/config'
|
||||
import I18n from '@/context/i18n'
|
||||
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
import LogoSite from '@/app/components/base/logo/logo-site'
|
||||
|
||||
type IAccountSettingProps = {
|
||||
@@ -26,7 +26,6 @@ export default function AccountAbout({
|
||||
}: IAccountSettingProps) {
|
||||
const { t } = useTranslation()
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
const isLatest = langeniusVersionInfo.current_version === langeniusVersionInfo.latest_version
|
||||
|
||||
return (
|
||||
@@ -49,8 +48,8 @@ export default function AccountAbout({
|
||||
IS_CE_EDITION
|
||||
? <Link href={'https://github.com/langgenius/dify/blob/main/LICENSE'} target='_blank' rel='noopener noreferrer'>Open Source License</Link>
|
||||
: <>
|
||||
<Link href={language !== LanguagesSupportedUnderscore[1] ? 'https://docs.dify.ai/user-agreement/privacy-policy' : 'https://docs.dify.ai/v/zh-hans/user-agreement/privacy-policy'} target='_blank' rel='noopener noreferrer'>Privacy Policy</Link>,
|
||||
<Link href={language !== LanguagesSupportedUnderscore[1] ? 'https://docs.dify.ai/user-agreement/terms-of-service' : 'https://docs.dify.ai/v/zh-hans/user-agreement/terms-of-service'} target='_blank' rel='noopener noreferrer'>Terms of Service</Link>
|
||||
<Link href={locale !== LanguagesSupported[1] ? 'https://docs.dify.ai/user-agreement/privacy-policy' : 'https://docs.dify.ai/v/zh-hans/user-agreement/privacy-policy'} target='_blank' rel='noopener noreferrer'>Privacy Policy</Link>,
|
||||
<Link href={locale !== LanguagesSupported[1] ? 'https://docs.dify.ai/user-agreement/terms-of-service' : 'https://docs.dify.ai/v/zh-hans/user-agreement/terms-of-service'} target='_blank' rel='noopener noreferrer'>Terms of Service</Link>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@ import { useAppContext } from '@/context/app-context'
|
||||
import { ArrowUpRight, ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||
import { LogOut01 } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
export type IAppSelecotr = {
|
||||
isMobile: boolean
|
||||
}
|
||||
@@ -30,7 +30,6 @@ export default function AppSelector({ isMobile }: IAppSelecotr) {
|
||||
const [aboutVisible, setAboutVisible] = useState(false)
|
||||
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
const { t } = useTranslation()
|
||||
const { userProfile, langeniusVersionInfo } = useAppContext()
|
||||
const { setShowAccountSettingModal } = useModalContext()
|
||||
@@ -123,7 +122,7 @@ export default function AppSelector({ isMobile }: IAppSelecotr) {
|
||||
<Link
|
||||
className={classNames(itemClassName, 'group justify-between')}
|
||||
href={
|
||||
language !== LanguagesSupportedUnderscore[1] ? 'https://docs.dify.ai/' : `https://docs.dify.ai/v/${locale.toLowerCase()}/`
|
||||
locale !== LanguagesSupported[1] ? 'https://docs.dify.ai/' : `https://docs.dify.ai/v/${locale.toLowerCase()}/`
|
||||
}
|
||||
target='_blank' rel='noopener noreferrer'>
|
||||
<div>{t('common.userProfile.helpCenter')}</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { updateUserProfile } from '@/service/common'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import I18n from '@/context/i18n'
|
||||
import { timezones } from '@/utils/timezone'
|
||||
import { languages } from '@/utils/language'
|
||||
import { languages } from '@/i18n/language'
|
||||
|
||||
const titleClassName = `
|
||||
mb-2 text-sm font-medium text-gray-900
|
||||
@@ -53,7 +53,7 @@ export default function LanguagePage() {
|
||||
<div className={titleClassName}>{t('common.language.displayLanguage')}</div>
|
||||
<SimpleSelect
|
||||
defaultValue={locale || userProfile.interface_language}
|
||||
items={languages}
|
||||
items={languages.filter(item => item.supported)}
|
||||
onSelect={item => handleSelect('language', item)}
|
||||
disabled={editing}
|
||||
/>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { useProviderContext } from '@/context/provider-context'
|
||||
import { Plan } from '@/app/components/billing/type'
|
||||
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
|
||||
import { NUM_INFINITE } from '@/app/components/billing/config'
|
||||
import { LanguagesSupportedUnderscore, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { LanguagesSupported } from '@/i18n/language'
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const MembersPage = () => {
|
||||
@@ -31,7 +31,7 @@ const MembersPage = () => {
|
||||
normal: t('common.members.normal'),
|
||||
}
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
|
||||
const { userProfile, currentWorkspace, isCurrentWorkspaceManager } = useAppContext()
|
||||
const { data, mutate } = useSWR({ url: '/workspaces/current/members' }, fetchMembers)
|
||||
const [inviteModalVisible, setInviteModalVisible] = useState(false)
|
||||
@@ -55,7 +55,7 @@ const MembersPage = () => {
|
||||
{isNotUnlimitedMemberPlan
|
||||
? (
|
||||
<div className='flex space-x-1'>
|
||||
<div>{t('billing.plansCommon.member')}{language !== LanguagesSupportedUnderscore[1] && accounts.length > 1 && 's'}</div>
|
||||
<div>{t('billing.plansCommon.member')}{locale !== LanguagesSupported[1] && accounts.length > 1 && 's'}</div>
|
||||
<div className='text-gray-700'>{accounts.length}</div>
|
||||
<div>/</div>
|
||||
<div>{plan.total.teamMembers === NUM_INFINITE ? t('billing.plansCommon.unlimited') : plan.total.teamMembers}</div>
|
||||
@@ -64,7 +64,7 @@ const MembersPage = () => {
|
||||
: (
|
||||
<div className='flex space-x-1'>
|
||||
<div>{accounts.length}</div>
|
||||
<div>{t('billing.plansCommon.memberAfter')}{language !== LanguagesSupportedUnderscore[1] && accounts.length > 1 && 's'}</div>
|
||||
<div>{t('billing.plansCommon.memberAfter')}{locale !== LanguagesSupported[1] && accounts.length > 1 && 's'}</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,6 @@ import { emailRegex } from '@/config'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
import type { InvitationResult } from '@/models/common'
|
||||
import I18n from '@/context/i18n'
|
||||
import { getModelRuntimeSupported } from '@/utils/language'
|
||||
|
||||
import 'react-multi-email/dist/style.css'
|
||||
type IInviteModalProps = {
|
||||
@@ -32,7 +31,6 @@ const InviteModal = ({
|
||||
const { notify } = useContext(ToastContext)
|
||||
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
|
||||
const InvitingRoles = useMemo(() => [
|
||||
{
|
||||
@@ -51,7 +49,7 @@ const InviteModal = ({
|
||||
try {
|
||||
const { result, invitation_results } = await inviteMember({
|
||||
url: '/workspaces/current/members/invite-email',
|
||||
body: { emails, role: role.name, language },
|
||||
body: { emails, role: role.name, language: locale },
|
||||
})
|
||||
|
||||
if (result === 'success') {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export type FormValue = Record<string, any>
|
||||
|
||||
export type TypeWithI18N<T = string> = {
|
||||
'en_US': T
|
||||
'zh_Hans': T
|
||||
'en-US': T
|
||||
'zh-Hans': T
|
||||
[key: string]: T
|
||||
}
|
||||
|
||||
@@ -67,16 +67,16 @@ export enum ModelStatusEnum {
|
||||
|
||||
export const MODEL_STATUS_TEXT: { [k: string]: TypeWithI18N } = {
|
||||
'no-configure': {
|
||||
en_US: 'No Configure',
|
||||
zh_Hans: '未配置凭据',
|
||||
'en-US': 'No Configure',
|
||||
'zh-Hans': '未配置凭据',
|
||||
},
|
||||
'quota-exceeded': {
|
||||
en_US: 'Quota Exceeded',
|
||||
zh_Hans: '额度不足',
|
||||
'en-US': 'Quota Exceeded',
|
||||
'zh-Hans': '额度不足',
|
||||
},
|
||||
'no-permission': {
|
||||
en_US: 'No Permission',
|
||||
zh_Hans: '无使用权限',
|
||||
'en-US': 'No Permission',
|
||||
'zh-Hans': '无使用权限',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
ConfigurateMethodEnum,
|
||||
ModelTypeEnum,
|
||||
} from './declarations'
|
||||
import { getModelRuntimeSupported } from '@/utils/language'
|
||||
import I18n from '@/context/i18n'
|
||||
import {
|
||||
fetchDefaultModal,
|
||||
@@ -59,7 +58,7 @@ export const useSystemDefaultModelAndModelList: UseDefaultModelAndModelList = (
|
||||
|
||||
export const useLanguage = () => {
|
||||
const { locale } = useContext(I18n)
|
||||
return getModelRuntimeSupported(locale)
|
||||
return locale.replace('-', '_')
|
||||
}
|
||||
|
||||
export const useProviderCrenditialsFormSchemasValue = (
|
||||
|
||||
@@ -2,11 +2,10 @@ import { useState } from 'react'
|
||||
import { useContext } from 'use-context-selector'
|
||||
import I18n from '@/context/i18n'
|
||||
import { X } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { NOTICE_I18N, getModelRuntimeSupported } from '@/utils/language'
|
||||
import { NOTICE_I18N } from '@/i18n/language'
|
||||
|
||||
const MaintenanceNotice = () => {
|
||||
const { locale } = useContext(I18n)
|
||||
const language = getModelRuntimeSupported(locale)
|
||||
|
||||
const [showNotice, setShowNotice] = useState(localStorage.getItem('hide-maintenance-notice') !== '1')
|
||||
const handleJumpNotice = () => {
|
||||
@@ -26,11 +25,11 @@ const MaintenanceNotice = () => {
|
||||
|
||||
return (
|
||||
<div className='shrink-0 flex items-center px-4 h-[38px] bg-[#FFFAEB] border-b border-[0.5px] border-b-[#FEF0C7] z-20'>
|
||||
<div className='shrink-0 flex items-center mr-2 px-2 h-[22px] bg-[#F79009] text-white text-[11px] font-medium rounded-xl'>{titleByLocale[language]}</div>
|
||||
<div className='shrink-0 flex items-center mr-2 px-2 h-[22px] bg-[#F79009] text-white text-[11px] font-medium rounded-xl'>{titleByLocale[locale]}</div>
|
||||
{
|
||||
(NOTICE_I18N.href && NOTICE_I18N.href !== '#')
|
||||
? <div className='grow text-xs font-medium text-gray-700 cursor-pointer' onClick={handleJumpNotice}>{descByLocale[language]}</div>
|
||||
: <div className='grow text-xs font-medium text-gray-700'>{descByLocale[language]}</div>
|
||||
? <div className='grow text-xs font-medium text-gray-700 cursor-pointer' onClick={handleJumpNotice}>{descByLocale[locale]}</div>
|
||||
: <div className='grow text-xs font-medium text-gray-700'>{descByLocale[locale]}</div>
|
||||
}
|
||||
<X className='shrink-0 w-4 h-4 text-gray-500 cursor-pointer' onClick={handleCloseNotice} />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user