Feat/i18n restructure (#2529)

This commit is contained in:
crazywoola 2024-02-23 14:31:06 +08:00 • committed by GitHub
commit 9574730050
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 448 additions and 659 deletions

View file

@ -10,7 +10,7 @@ import Button from '@/app/components/base/button'
import Drawer from '@/app/components/base/drawer-plus'
import I18n from '@/context/i18n'
import { testAPIAvailable } from '@/service/tools'
import { getModelRuntimeSupported } from '@/utils/language'
import { getLanguage } from '@/i18n/language'
type Props = {
customCollection: CustomCollectionBackend
@ -27,7 +27,7 @@ const TestApi: FC<Props> = ({
}) => {
const { t } = useTranslation()
const { locale } = useContext(I18n)
const language = getModelRuntimeSupported(locale)
const language = getLanguage(locale)
const [credentialsModalShow, setCredentialsModalShow] = useState(false)
const [tempCredential, setTempCredential] = React.useState<Credential>(customCollection.credentials)
const [result, setResult] = useState<string>('')

View file

@ -8,8 +8,7 @@ import type { Collection } from '../types'
import { CollectionType, LOC } from '../types'
import { Settings01 } from '../../base/icons/src/vender/line/general'
import I18n from '@/context/i18n'
import { getModelRuntimeSupported } from '@/utils/language'
import { getLanguage } from '@/i18n/language'
type Props = {
icon: JSX.Element
collection: Collection
@ -26,7 +25,7 @@ const Header: FC<Props> = ({
onShowEditCustomCollection,
}) => {
const { locale } = useContext(I18n)
const language = getModelRuntimeSupported(locale)
const language = getLanguage(locale)
const { t } = useTranslation()
const isInToolsPage = loc === LOC.tools
const isInDebugPage = !isInToolsPage

View file

@ -10,8 +10,7 @@ import { CollectionType } from '../types'
import TooltipPlus from '../../base/tooltip-plus'
import I18n from '@/context/i18n'
import SettingBuiltInTool from '@/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool'
import { getModelRuntimeSupported } from '@/utils/language'
import { getLanguage } from '@/i18n/language'
type Props = {
collection: Collection
icon: JSX.Element
@ -33,7 +32,8 @@ const Item: FC<Props> = ({
}) => {
const { t } = useTranslation()
const { locale } = useContext(I18n)
const language = getModelRuntimeSupported(locale)
const language = getLanguage(locale)
const isBuiltIn = collection.type === CollectionType.builtIn
const canShowDetail = !isBuiltIn || (isBuiltIn && isInToolsPage)
const [showDetail, setShowDetail] = useState(false)

View file

@ -6,7 +6,7 @@ import cn from 'classnames'
import AppIcon from '../../base/app-icon'
import type { Collection } from '@/app/components/tools/types'
import I18n from '@/context/i18n'
import { getModelRuntimeSupported } from '@/utils/language'
import { getLanguage } from '@/i18n/language'
type Props = {
isCurrent: boolean
@ -20,7 +20,7 @@ const Item: FC<Props> = ({
onClick,
}) => {
const { locale } = useContext(I18n)
const language = getModelRuntimeSupported(locale)
const language = getLanguage(locale)
return (
<div
className={cn(isCurrent && 'bg-white shadow-xs rounded-lg', 'mt-1 flex h-9 items-center px-2 space-x-2 cursor-pointer')}