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

@ -10,7 +10,7 @@ import { InstallStep } from '../../types'
import useHideLogic from '../hooks/use-hide-logic'
import ReadyToInstall from './ready-to-install'
const i18nPrefix = 'plugin.installModal'
const i18nPrefix = 'installModal'
export enum InstallType {
fromLocal = 'fromLocal',
@ -42,11 +42,11 @@ const InstallBundle: FC<Props> = ({
const getTitle = useCallback(() => {
if (step === InstallStep.uploadFailed)
return t(`${i18nPrefix}.uploadFailed`)
return t(`${i18nPrefix}.uploadFailed`, { ns: 'plugin' })
if (step === InstallStep.installed)
return t(`${i18nPrefix}.installComplete`)
return t(`${i18nPrefix}.installComplete`, { ns: 'plugin' })
return t(`${i18nPrefix}.installPlugin`)
return t(`${i18nPrefix}.installPlugin`, { ns: 'plugin' })
}, [step, t])
return (

View File

@ -20,7 +20,7 @@ import checkTaskStatus from '../../base/check-task-status'
import useRefreshPluginList from '../../hooks/use-refresh-plugin-list'
import InstallMulti from './install-multi'
const i18nPrefix = 'plugin.installModal'
const i18nPrefix = 'installModal'
type Props = {
allPlugins: Dependency[]
@ -173,7 +173,7 @@ const Install: 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}.${selectedPluginsNum > 1 ? 'readyToInstallPackages' : 'readyToInstallPackage'}`, { num: selectedPluginsNum })}</p>
<p>{t(`${i18nPrefix}.${selectedPluginsNum > 1 ? 'readyToInstallPackages' : 'readyToInstallPackage'}`, { ns: 'plugin', num: selectedPluginsNum })}</p>
</div>
<div className="w-full space-y-1 rounded-2xl bg-background-section-burn p-2">
<InstallMulti
@ -195,14 +195,14 @@ const Install: FC<Props> = ({
{canInstall && (
<div className="flex items-center gap-x-2" onClick={handleClickSelectAll}>
<Checkbox checked={isSelectAll} indeterminate={isIndeterminate} />
<p className="system-sm-medium cursor-pointer text-text-secondary">{isSelectAll ? t('common.operation.deSelectAll') : t('common.operation.selectAll')}</p>
<p className="system-sm-medium cursor-pointer text-text-secondary">{isSelectAll ? t('operation.deSelectAll', { ns: 'common' }) : t('operation.selectAll', { ns: 'common' })}</p>
</div>
)}
</div>
<div className="flex items-center justify-end gap-2 self-stretch">
{!canInstall && (
<Button variant="secondary" className="min-w-[72px]" onClick={handleCancel}>
{t('common.operation.cancel')}
{t('operation.cancel', { ns: 'common' })}
</Button>
)}
<Button
@ -212,7 +212,7 @@ const Install: 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>
</div>

View File

@ -54,7 +54,7 @@ const Installed: FC<Props> = ({
className="min-w-[72px]"
onClick={onCancel}
>
{t('common.operation.close')}
{t('operation.close', { ns: 'common' })}
</Button>
</div>
)}