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

@ -24,12 +24,12 @@ import Loading from '../components/base/loading'
const accountFormSchema = z.object({
email: z
.string()
.min(1, { message: 'login.error.emailInValid' })
.email('login.error.emailInValid'),
name: z.string().min(1, { message: 'login.error.nameEmpty' }),
.min(1, { message: 'error.emailInValid' })
.email('error.emailInValid'),
name: z.string().min(1, { message: 'error.nameEmpty' }),
password: z.string().min(8, {
message: 'login.error.passwordLengthInValid',
}).regex(validPassword, 'login.error.passwordInvalid'),
message: 'error.passwordLengthInValid',
}).regex(validPassword, 'error.passwordInvalid'),
})
type AccountFormValues = z.infer<typeof accountFormSchema>
@ -122,50 +122,50 @@ const InstallForm = () => {
: (
<>
<div className="sm:mx-auto sm:w-full sm:max-w-md">
<h2 className="text-[32px] font-bold text-text-primary">{t('login.setAdminAccount')}</h2>
<p className="mt-1 text-sm text-text-secondary">{t('login.setAdminAccountDesc')}</p>
<h2 className="text-[32px] font-bold text-text-primary">{t('setAdminAccount', { ns: 'login' })}</h2>
<p className="mt-1 text-sm text-text-secondary">{t('setAdminAccountDesc', { ns: 'login' })}</p>
</div>
<div className="mt-8 grow sm:mx-auto sm:w-full sm:max-w-md">
<div className="relative">
<form onSubmit={handleSubmit(onSubmit)} onKeyDown={handleKeyDown}>
<div className="mb-5">
<label htmlFor="email" className="my-2 flex items-center justify-between text-sm font-medium text-text-primary">
{t('login.email')}
{t('email', { ns: 'login' })}
</label>
<div className="mt-1 rounded-md shadow-sm">
<input
{...register('email')}
placeholder={t('login.emailPlaceholder') || ''}
placeholder={t('emailPlaceholder', { ns: 'login' }) || ''}
className="system-sm-regular w-full appearance-none rounded-md border border-transparent bg-components-input-bg-normal px-3 py-[7px] text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs"
/>
{errors.email && <span className="text-sm text-red-400">{t(`${errors.email?.message}` as any) as string}</span>}
{errors.email && <span className="text-sm text-red-400">{t(`${errors.email?.message}` as 'error.emailInValid', { ns: 'login' })}</span>}
</div>
</div>
<div className="mb-5">
<label htmlFor="name" className="my-2 flex items-center justify-between text-sm font-medium text-text-primary">
{t('login.name')}
{t('name', { ns: 'login' })}
</label>
<div className="relative mt-1 rounded-md shadow-sm">
<input
{...register('name')}
placeholder={t('login.namePlaceholder') || ''}
placeholder={t('namePlaceholder', { ns: 'login' }) || ''}
className="system-sm-regular w-full appearance-none rounded-md border border-transparent bg-components-input-bg-normal px-3 py-[7px] text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs"
/>
</div>
{errors.name && <span className="text-sm text-red-400">{t(`${errors.name.message}` as any) as string}</span>}
{errors.name && <span className="text-sm text-red-400">{t(`${errors.name.message}` as 'error.nameEmpty', { ns: 'login' })}</span>}
</div>
<div className="mb-5">
<label htmlFor="password" className="my-2 flex items-center justify-between text-sm font-medium text-text-primary">
{t('login.password')}
{t('password', { ns: 'login' })}
</label>
<div className="relative mt-1 rounded-md shadow-sm">
<input
{...register('password')}
type={showPassword ? 'text' : 'password'}
placeholder={t('login.passwordPlaceholder') || ''}
placeholder={t('passwordPlaceholder', { ns: 'login' }) || ''}
className="system-sm-regular w-full appearance-none rounded-md border border-transparent bg-components-input-bg-normal px-3 py-[7px] text-components-input-text-filled caret-primary-600 outline-none placeholder:text-components-input-text-placeholder hover:border-components-input-border-hover hover:bg-components-input-bg-hover focus:border-components-input-border-active focus:bg-components-input-bg-active focus:shadow-xs"
/>
@ -184,18 +184,18 @@ const InstallForm = () => {
'text-red-400 !text-sm': errors.password,
})}
>
{t('login.error.passwordInvalid')}
{t('error.passwordInvalid', { ns: 'login' })}
</div>
</div>
<div>
<Button variant="primary" className="w-full" onClick={handleSetting}>
{t('login.installBtn')}
{t('installBtn', { ns: 'login' })}
</Button>
</div>
</form>
<div className="mt-2 block w-full text-xs text-text-secondary">
{t('login.license.tip')}
{t('license.tip', { ns: 'login' })}
&nbsp;
<Link
className="text-text-accent"
@ -203,7 +203,7 @@ const InstallForm = () => {
rel="noopener noreferrer"
href={docLink('/policies/open-source')}
>
{t('login.license.link')}
{t('license.link', { ns: 'login' })}
</Link>
</div>
</div>