refactor(i18n): use JSON with flattened key and namespace (#30114)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Stephen Zhou
2025-12-29 14:52:32 +08:00
committed by GitHub
parent 09be869f58
commit 6d0e36479b
2552 changed files with 111159 additions and 142972 deletions

View File

@ -13,7 +13,7 @@ import ReadyToInstallBundle from '../install-bundle/ready-to-install'
import ReadyToInstallPackage from './ready-to-install'
import Uploading from './steps/uploading'
const i18nPrefix = 'plugin.installModal'
const i18nPrefix = 'installModal'
type InstallFromLocalPackageProps = {
file: File
@ -43,15 +43,15 @@ const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
const getTitle = useCallback(() => {
if (step === InstallStep.uploadFailed)
return t(`${i18nPrefix}.uploadFailed`)
return t(`${i18nPrefix}.uploadFailed`, { ns: 'plugin' })
if (isBundle && step === InstallStep.installed)
return t(`${i18nPrefix}.installComplete`)
return t(`${i18nPrefix}.installComplete`, { ns: 'plugin' })
if (step === InstallStep.installed)
return t(`${i18nPrefix}.installedSuccessfully`)
return t(`${i18nPrefix}.installedSuccessfully`, { ns: 'plugin' })
if (step === InstallStep.installFailed)
return t(`${i18nPrefix}.installFailed`)
return t(`${i18nPrefix}.installFailed`, { ns: 'plugin' })
return t(`${i18nPrefix}.installPlugin`)
return t(`${i18nPrefix}.installPlugin`, { ns: 'plugin' })
}, [isBundle, step, t])
const { getIconUrl } = useGetIcon()

View File

@ -17,7 +17,7 @@ import checkTaskStatus from '../../base/check-task-status'
import Version from '../../base/version'
import { pluginManifestToCardPluginProps } from '../../utils'
const i18nPrefix = 'plugin.installModal'
const i18nPrefix = 'installModal'
type Props = {
uniqueIdentifier: string
@ -118,7 +118,7 @@ const Installed: FC<Props> = ({
<>
<div className="flex flex-col items-start justify-center gap-4 self-stretch px-6 py-3">
<div className="system-md-regular text-text-secondary">
<p>{t(`${i18nPrefix}.readyToInstall`)}</p>
<p>{t(`${i18nPrefix}.readyToInstall`, { ns: 'plugin' })}</p>
<p>
<Trans
i18nKey={`${i18nPrefix}.fromTrustSource`}
@ -127,7 +127,7 @@ const Installed: FC<Props> = ({
</p>
{!isDifyVersionCompatible && (
<p className="system-md-regular flex items-center gap-1 text-text-warning">
{t('plugin.difyVersionNotCompatible', { minimalDifyVersion: payload.meta.minimum_dify_version })}
{t('difyVersionNotCompatible', { ns: 'plugin', minimalDifyVersion: payload.meta.minimum_dify_version })}
</p>
)}
</div>
@ -149,7 +149,7 @@ const Installed: FC<Props> = ({
<div className="flex items-center justify-end gap-2 self-stretch p-6 pt-5">
{!isInstalling && (
<Button variant="secondary" className="min-w-[72px]" onClick={handleCancel}>
{t('common.operation.cancel')}
{t('operation.cancel', { ns: 'common' })}
</Button>
)}
<Button
@ -159,7 +159,7 @@ const Installed: FC<Props> = ({
onClick={handleInstall}
>
{isInstalling && <RiLoader2Line className="h-4 w-4 animate-spin-slow" />}
<span>{t(`${i18nPrefix}.${isInstalling ? 'installing' : 'install'}`)}</span>
<span>{t(`${i18nPrefix}.${isInstalling ? 'installing' : 'install'}`, { ns: 'plugin' })}</span>
</Button>
</div>
</>

View File

@ -8,7 +8,7 @@ import Button from '@/app/components/base/button'
import { uploadFile } from '@/service/plugins'
import Card from '../../../card'
const i18nPrefix = 'plugin.installModal'
const i18nPrefix = 'installModal'
type Props = {
isBundle: boolean
@ -64,6 +64,7 @@ const Uploading: FC<Props> = ({
<RiLoader2Line className="h-4 w-4 animate-spin-slow text-text-accent" />
<div className="system-md-regular text-text-secondary">
{t(`${i18nPrefix}.uploadingPackage`, {
ns: 'plugin',
packageName: fileName,
})}
</div>
@ -82,14 +83,14 @@ const Uploading: FC<Props> = ({
{/* Action Buttons */}
<div className="flex items-center justify-end gap-2 self-stretch p-6 pt-5">
<Button variant="secondary" className="min-w-[72px]" onClick={onCancel}>
{t('common.operation.cancel')}
{t('operation.cancel', { ns: 'common' })}
</Button>
<Button
variant="primary"
className="min-w-[72px]"
disabled
>
{t(`${i18nPrefix}.install`)}
{t(`${i18nPrefix}.install`, { ns: 'plugin' })}
</Button>
</div>
</>