I18n Translations (#2267)

* rebase

* i18n-1

* add error info i18n

* fix

* fix

* refactor: 删除error.json

* delete useI18n
This commit is contained in:
papapatrick
2024-08-05 18:42:21 +08:00
committed by GitHub
parent 025d405fe2
commit 10dcdb5491
107 changed files with 1128 additions and 416 deletions

View File

@@ -33,9 +33,10 @@ import MySelect from '@fastgpt/web/components/common/MySelect';
import MyModal from '@fastgpt/web/components/common/MyModal';
import { usePagination } from '@fastgpt/web/hooks/usePagination';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
import { useI18n } from '@/web/context/I18n';
const BillTable = () => {
const { t } = useTranslation();
const { commonT } = useI18n();
const { toast } = useToast();
const [billType, setBillType] = useState<BillTypeEnum | ''>('');
const [billDetail, setBillDetail] = useState<BillSchemaType>();
@@ -134,7 +135,7 @@ const BillTable = () => {
<Td>
{item.createTime ? dayjs(item.createTime).format('YYYY/MM/DD HH:mm:ss') : '-'}
</Td>
<Td>{formatStorePrice2Read(item.price)}</Td>
<Td>{commonT('common:pay.yuan', { amount: formatStorePrice2Read(item.price) })}</Td>
<Td>{t(billStatusMap[item.status]?.label as any)}</Td>
<Td>
{item.status === 'NOTPAY' && (
@@ -181,7 +182,7 @@ export default BillTable;
function BillDetailModal({ bill, onClose }: { bill: BillSchemaType; onClose: () => void }) {
const { t } = useTranslation();
const { commonT } = useI18n();
return (
<MyModal
isOpen={true}
@@ -211,7 +212,7 @@ function BillDetailModal({ bill, onClose }: { bill: BillSchemaType; onClose: ()
)}
<Flex alignItems={'center'} pb={4}>
<FormLabel flex={'0 0 120px'}>{t('common:support.wallet.Amount')}:</FormLabel>
<Box>{formatStorePrice2Read(bill.price)}</Box>
<Box>{commonT('common:pay.yuan', { amount: formatStorePrice2Read(bill.price) })}</Box>
</Flex>
<Flex alignItems={'center'} pb={4}>
<FormLabel flex={'0 0 120px'}>{t('common:support.wallet.bill.Type')}:</FormLabel>

View File

@@ -435,7 +435,7 @@ const PlanUsage = () => {
<Box ml={2}>{formatTime2YMD(standardPlan?.expiredTime)}</Box>
</Flex>
<Box mt="2" color={'#485264'} fontSize="sm">
30使
{t('common:info.free_plan')}
</Box>
</>
) : (
@@ -470,9 +470,9 @@ const PlanUsage = () => {
>
<Flex>
<Flex flex={'1 0 0'} alignItems={'flex-end'}>
<Box fontSize={'md'}></Box>
<Box fontSize={'md'}>{t('common:info.resource')}</Box>
<Box fontSize={'xs'} color={'myGray.500'}>
()
{t('common:info.include')}
</Box>
</Flex>
<Link
@@ -484,7 +484,7 @@ const PlanUsage = () => {
cursor={'pointer'}
fontSize={'sm'}
>
{t('common:info.buy_extra')}
<MyIcon ml={1} name={'common/rightArrowLight'} w={'12px'} />
</Link>
</Flex>
@@ -567,7 +567,7 @@ const Other = () => {
});
reset(data);
toast({
title: '更新数据成功',
title: t('common:dataset.data.Update Success Tip'),
status: 'success'
});
},
@@ -637,7 +637,7 @@ const Other = () => {
>
<Image src="/imgs/workflow/laf.png" w={'18px'} alt="laf" />
<Box ml={2} flex={1}>
laf
{'laf' + t('common:navbar.Account')}
</Box>
<Box
w={'9px'}
@@ -664,7 +664,7 @@ const Other = () => {
>
<MyIcon name={'common/openai'} w={'18px'} color={'myGray.600'} />
<Box ml={2} flex={1}>
OpenAI/OneAPI
{'OpenAI / OneAPI' + t('common:navbar.Account')}
</Box>
<Box
w={'9px'}

View File

@@ -81,7 +81,9 @@ const InformTable = () => {
)}
</Box>
))}
{!isLoading && informs.length === 0 && <EmptyTip text={'暂无通知~'}></EmptyTip>}
{!isLoading && informs.length === 0 && (
<EmptyTip text={t('common:user.no_notice')}></EmptyTip>
)}
</Box>
{total > pageSize && (

View File

@@ -37,9 +37,7 @@ const OpenAIAccountModal = ({
>
<ModalBody>
<Box fontSize={'sm'} color={'myGray.500'}>
OpenAI/OneAPI
线使AI对话Key
Key 访GPT模型可以选择 FastAI
{t('common:info.open_api_notice')}
</Box>
<Flex alignItems={'center'} mt={5}>
<Box flex={'0 0 65px'}>API Key:</Box>
@@ -50,16 +48,16 @@ const OpenAIAccountModal = ({
<Input
flex={1}
{...register('baseUrl')}
placeholder={'请求地址,默认为 openai 官方。可填中转地址,未自动补全 "v1"'}
placeholder={t('common:info.open_api_placeholder')}
></Input>
</Flex>
</ModalBody>
<ModalFooter>
<Button mr={3} variant={'whiteBase'} onClick={onClose}>
{t('common:common.Cancel')}
</Button>
<Button isLoading={isLoading} onClick={handleSubmit((data) => onSubmit(data))}>
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>

View File

@@ -7,7 +7,6 @@ import { getErrText } from '@fastgpt/global/common/error/utils';
import { useTranslation } from 'next-i18next';
import MyModal from '@fastgpt/web/components/common/MyModal';
import { BillTypeEnum } from '@fastgpt/global/support/wallet/bill/constants';
import QRCodePayModal, { type QRPayProps } from '@/components/support/wallet/QRCodePayModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { EXTRA_PLAN_CARD_ROUTE } from '@/web/support/wallet/sub/constants';
@@ -27,7 +26,6 @@ const PayModal = ({
const [inputVal, setInputVal] = useState<number | undefined>(defaultValue);
const [loading, setLoading] = useState(false);
const [qrPayData, setQRPayData] = useState<QRPayProps>();
const handleClickPay = useCallback(async () => {
if (!inputVal || inputVal <= 0 || isNaN(+inputVal)) return;
setLoading(true);
@@ -79,7 +77,7 @@ const PayModal = ({
variant={item === inputVal ? 'solid' : 'outline'}
onClick={() => setInputVal(item)}
>
{item}
{t('common:pay.yuan', { amount: item })}
</Button>
))}
</Grid>
@@ -88,7 +86,7 @@ const PayModal = ({
value={inputVal}
type={'number'}
step={1}
placeholder={'其他金额,请取整数'}
placeholder={t('common:pay.other')}
onChange={(e) => {
setInputVal(Math.floor(+e.target.value));
}}
@@ -106,7 +104,7 @@ const PayModal = ({
isDisabled={!inputVal || inputVal === 0}
onClick={handleClickPay}
>
{t('common:pay.get_pay_QR')}
</Button>
</ModalFooter>

View File

@@ -105,9 +105,9 @@ const Promotion = () => {
<Table>
<Thead>
<Tr>
<Th></Th>
<Th></Th>
<Th>()</Th>
<Th>{t('common:user.Time')}</Th>
<Th>{t('common:user.type')}</Th>
<Th>{t('common:pay.amount')}</Th>
</Tr>
</Thead>
<Tbody fontSize={'sm'}>
@@ -124,7 +124,9 @@ const Promotion = () => {
</Table>
</TableContainer>
{!isLoading && promotionRecords.length === 0 && <EmptyTip text="无邀请记录~"></EmptyTip>}
{!isLoading && promotionRecords.length === 0 && (
<EmptyTip text={t('common:user.no_invite_records')}></EmptyTip>
)}
{total > pageSize && (
<Flex mt={4} justifyContent={'flex-end'}>
<Pagination />

View File

@@ -70,16 +70,16 @@ const UpdateNotificationModal = ({ onClose }: { onClose: () => void }) => {
flex={1}
bg={'myGray.50'}
{...register('account', { required: true })}
placeholder={t('common:support.user.Email Or Phone')}
placeholder={t('user:password.email_phone')}
></Input>
</Flex>
<Flex mt="6" alignItems="center" position={'relative'}>
<Box flex={'0 0 70px'}>{t('common:support.user.Verify Code')}</Box>
<Box flex={'0 0 70px'}>{t('user:password.verification_code')}</Box>
<Input
flex={1}
bg={'myGray.50'}
{...register('verifyCode', { required: true })}
placeholder={t('common:support.user.Verify Code')}
placeholder={t('user:password.code_required')}
></Input>
<Box
position={'absolute'}

View File

@@ -45,11 +45,11 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
>
<ModalBody>
<Flex alignItems={'center'}>
<Box flex={'0 0 70px'}>:</Box>
<Box flex={'0 0 70px'}>{t('common:user.old_password') + ':'}</Box>
<Input flex={1} type={'password'} {...register('oldPsw', { required: true })}></Input>
</Flex>
<Flex alignItems={'center'} mt={5}>
<Box flex={'0 0 70px'}>:</Box>
<Box flex={'0 0 70px'}>{t('common:user.new_password') + ':'}</Box>
<Input
flex={1}
type={'password'}
@@ -57,13 +57,13 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
required: true,
maxLength: {
value: 60,
message: '密码最少 4 位最多 60 位'
message: t('common:user.password_message')
}
})}
></Input>
</Flex>
<Flex alignItems={'center'} mt={5}>
<Box flex={'0 0 70px'}>:</Box>
<Box flex={'0 0 70px'}>{t('common:user.confirm_password') + ':'}</Box>
<Input
flex={1}
type={'password'}
@@ -71,7 +71,7 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
required: true,
maxLength: {
value: 60,
message: '密码最少 4 位最多 60 位'
message: t('common:user.password_message')
}
})}
></Input>
@@ -79,10 +79,10 @@ const UpdatePswModal = ({ onClose }: { onClose: () => void }) => {
</ModalBody>
<ModalFooter>
<Button mr={3} variant={'whiteBase'} onClick={onClose}>
{t('common:common.Cancel')}
</Button>
<Button isLoading={isLoading} onClick={handleSubmit((data) => onSubmit(data))}>
{t('common:common.Confirm')}
</Button>
</ModalFooter>
</MyModal>

View File

@@ -174,7 +174,7 @@ const UsageTable = () => {
<Td>{formatNumber(item.totalPoints) || 0}</Td>
<Td>
<Button size={'sm'} variant={'whitePrimary'} onClick={() => setUsageDetail(item)}>
{t('common:common.Detail')}
</Button>
</Td>
</Tr>
@@ -183,7 +183,9 @@ const UsageTable = () => {
</Table>
</TableContainer>
{!isLoading && usages.length === 0 && <EmptyTip text="无使用记录~"></EmptyTip>}
{!isLoading && usages.length === 0 && (
<EmptyTip text={t('common:user.no_usage_records')}></EmptyTip>
)}
<Loading loading={isLoading} fixed={false} />
{!!usageDetail && (

View File

@@ -77,10 +77,12 @@ const StandDetailModal = ({ onClose }: { onClose: () => void }) => {
{currentSubLevel &&
`(${t(standardSubLevelMap[currentSubLevel]?.label as any)})`}
</Td>
<Td>{datasetSize ? `${datasetSize}` : '-'}</Td>
<Td>
{datasetSize ? `${datasetSize + t('common:core.dataset.data.group')}` : '-'}
</Td>
<Td>
{totalPoints
? `${Math.round(totalPoints - surplusPoints)} / ${totalPoints} 积分`
? `${Math.round(totalPoints - surplusPoints)} / ${totalPoints} ${t('common:support.wallet.subscription.point')}`
: '-'}
</Td>
<Td>{formatTime2YMDHM(startTime)}</Td>

View File

@@ -104,7 +104,7 @@ const Account = ({ currentTab }: { currentTab: TabEnum }) => {
];
const { openConfirm, ConfirmModal } = useConfirm({
content: '确认退出登录?'
content: t('common:support.user.logout.confirm')
});
const router = useRouter();