mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
I18n Translations (#2267)
* rebase * i18n-1 * add error info i18n * fix * fix * refactor: 删除error.json * delete useI18n
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 502000 */
|
||||
export enum AppErrEnum {
|
||||
unExist = 'appUnExist',
|
||||
@@ -8,11 +8,11 @@ export enum AppErrEnum {
|
||||
const appErrList = [
|
||||
{
|
||||
statusText: AppErrEnum.unExist,
|
||||
message: '应用不存在'
|
||||
message: i18nT('common:code_error.app_error.not_exist')
|
||||
},
|
||||
{
|
||||
statusText: AppErrEnum.unAuthApp,
|
||||
message: '无权操作该应用'
|
||||
message: i18nT('common:code_error.app_error.un_auth_app')
|
||||
}
|
||||
];
|
||||
export default appErrList.reduce((acc, cur, index) => {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 504000 */
|
||||
export enum ChatErrEnum {
|
||||
unAuthChat = 'unAuthChat'
|
||||
@@ -7,7 +7,7 @@ export enum ChatErrEnum {
|
||||
const errList = [
|
||||
{
|
||||
statusText: ChatErrEnum.unAuthChat,
|
||||
message: '无权操作该对话记录'
|
||||
message: i18nT('common:code_error.chat_error.un_auth')
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
|
@@ -1,25 +1,27 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 506000 */
|
||||
export enum OpenApiErrEnum {
|
||||
unExist = 'openapiUnExist',
|
||||
unAuth = 'openapiUnAuth',
|
||||
exceedLimit = 'openapiExceedLimit'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: OpenApiErrEnum.unExist,
|
||||
message: 'Api Key 不存在'
|
||||
message: i18nT('common:code_error.openapi_error.api_key_not_exist')
|
||||
},
|
||||
{
|
||||
statusText: OpenApiErrEnum.unAuth,
|
||||
message: '无权操作该 Api Key'
|
||||
message: i18nT('common:code_error.openapi_error.un_auth')
|
||||
},
|
||||
{
|
||||
statusText: OpenApiErrEnum.exceedLimit,
|
||||
message: '最多 10 组 API 密钥'
|
||||
message: i18nT('common:code_error.openapi_error.exceed_limit')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
@@ -1,32 +1,33 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 505000 */
|
||||
export enum OutLinkErrEnum {
|
||||
unExist = 'outlinkUnExist',
|
||||
unAuthLink = 'unAuthLink',
|
||||
linkUnInvalid = 'linkUnInvalid',
|
||||
|
||||
unAuthUser = 'unAuthUser'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: OutLinkErrEnum.unExist,
|
||||
message: '分享链接不存在'
|
||||
message: i18nT('common:code_error.outlink_error.link_not_exist')
|
||||
},
|
||||
{
|
||||
statusText: OutLinkErrEnum.unAuthLink,
|
||||
message: '分享链接无效'
|
||||
message: i18nT('common:code_error.outlink_error.invalid_link')
|
||||
},
|
||||
{
|
||||
code: 501,
|
||||
statusText: OutLinkErrEnum.linkUnInvalid,
|
||||
message: '分享链接无效'
|
||||
message: i18nT('common:code_error.outlink_error.invalid_link') // 使用相同的错误消息
|
||||
},
|
||||
{
|
||||
statusText: OutLinkErrEnum.unAuthUser,
|
||||
message: '身份校验失败'
|
||||
message: i18nT('common:code_error.outlink_error.un_auth_user')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
@@ -1,20 +1,22 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 508000 */
|
||||
export enum PluginErrEnum {
|
||||
unExist = 'pluginUnExist',
|
||||
unAuth = 'pluginUnAuth'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: PluginErrEnum.unExist,
|
||||
message: '插件不存在'
|
||||
message: i18nT('common:code_error.plugin_error.not_exist')
|
||||
},
|
||||
{
|
||||
statusText: PluginErrEnum.unAuth,
|
||||
message: '无权操作该插件'
|
||||
message: i18nT('common:code_error.plugin_error.un_auth')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
@@ -1,15 +1,17 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 509000 */
|
||||
export enum SystemErrEnum {
|
||||
communityVersionNumLimit = 'communityVersionNumLimit'
|
||||
}
|
||||
|
||||
const systemErr = [
|
||||
{
|
||||
statusText: SystemErrEnum.communityVersionNumLimit,
|
||||
message: '超出开源版数量限制,请升级商业版: https://fastgpt.in'
|
||||
message: i18nT('common:code_error.system_error.community_version_num_limit')
|
||||
}
|
||||
];
|
||||
|
||||
export default systemErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* team: 500000 */
|
||||
export enum TeamErrEnum {
|
||||
teamOverSize = 'teamOverSize',
|
||||
@@ -12,17 +12,43 @@ export enum TeamErrEnum {
|
||||
websiteSyncNotEnough = 'websiteSyncNotEnough',
|
||||
reRankNotEnough = 'reRankNotEnough'
|
||||
}
|
||||
|
||||
const teamErr = [
|
||||
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
|
||||
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' },
|
||||
{ statusText: TeamErrEnum.aiPointsNotEnough, message: '' },
|
||||
{ statusText: TeamErrEnum.datasetSizeNotEnough, message: '知识库容量不足,请先扩容~' },
|
||||
{ statusText: TeamErrEnum.datasetAmountNotEnough, message: '知识库数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.appAmountNotEnough, message: '应用数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.pluginAmountNotEnough, message: '插件数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.websiteSyncNotEnough, message: '无权使用Web站点同步~' },
|
||||
{ statusText: TeamErrEnum.reRankNotEnough, message: '无权使用检索重排~' }
|
||||
{
|
||||
statusText: TeamErrEnum.teamOverSize,
|
||||
message: i18nT('common:code_error.team_error.over_size')
|
||||
},
|
||||
{ statusText: TeamErrEnum.unAuthTeam, message: i18nT('common:code_error.team_error.un_auth') },
|
||||
{
|
||||
statusText: TeamErrEnum.aiPointsNotEnough,
|
||||
message: i18nT('common:code_error.team_error.ai_points_not_enough')
|
||||
}, // 需要定义或留空
|
||||
{
|
||||
statusText: TeamErrEnum.datasetSizeNotEnough,
|
||||
message: i18nT('common:code_error.team_error.dataset_size_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.datasetAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.dataset_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.appAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.app_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.pluginAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.plugin_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.websiteSyncNotEnough,
|
||||
message: i18nT('common:code_error.team_error.website_sync_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.reRankNotEnough,
|
||||
message: i18nT('common:code_error.team_error.re_rank_not_enough')
|
||||
}
|
||||
];
|
||||
|
||||
export default teamErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* team: 503000 */
|
||||
export enum UserErrEnum {
|
||||
unAuthUser = 'unAuthUser',
|
||||
@@ -8,10 +8,22 @@ export enum UserErrEnum {
|
||||
balanceNotEnough = 'balanceNotEnough'
|
||||
}
|
||||
const errList = [
|
||||
{ statusText: UserErrEnum.unAuthUser, message: '找不到该用户' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您的身份校验未通过' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您当前身份为游客,无权操作' },
|
||||
{ statusText: UserErrEnum.balanceNotEnough, message: '账号余额不足~' }
|
||||
{
|
||||
statusText: UserErrEnum.unAuthUser,
|
||||
message: i18nT('common:code_error.user_error.un_auth_user')
|
||||
},
|
||||
{
|
||||
statusText: UserErrEnum.binVisitor,
|
||||
message: i18nT('common:code_error.user_error.bin_visitor')
|
||||
}, // 身份校验未通过
|
||||
{
|
||||
statusText: UserErrEnum.binVisitor,
|
||||
message: i18nT('common:code_error.user_error.bin_visitor_guest')
|
||||
}, // 游客身份
|
||||
{
|
||||
statusText: UserErrEnum.balanceNotEnough,
|
||||
message: i18nT('common:code_error.user_error.balance_not_enough')
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
|
@@ -8,24 +8,25 @@ import teamErr from './code/team';
|
||||
import userErr from './code/user';
|
||||
import commonErr from './code/common';
|
||||
import SystemErrEnum from './code/system';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
export const ERROR_CODE: { [key: number]: string } = {
|
||||
400: '请求失败',
|
||||
401: '无权访问',
|
||||
403: '紧张访问',
|
||||
404: '请求不存在',
|
||||
405: '请求方法错误',
|
||||
406: '请求的格式错误',
|
||||
410: '资源已删除',
|
||||
422: '验证错误',
|
||||
500: '服务器发生错误',
|
||||
502: '网关错误',
|
||||
503: '服务器暂时过载或维护',
|
||||
504: '网关超时'
|
||||
400: i18nT('common:code_error.error_code.400'),
|
||||
401: i18nT('common:code_error.error_code.401'),
|
||||
403: i18nT('common:code_error.error_code.403'),
|
||||
404: i18nT('common:code_error.error_code.404'),
|
||||
405: i18nT('common:code_error.error_code.405'),
|
||||
406: i18nT('common:code_error.error_code.406'),
|
||||
410: i18nT('common:code_error.error_code.410'),
|
||||
422: i18nT('common:code_error.error_code.422'),
|
||||
500: i18nT('common:code_error.error_code.500'),
|
||||
502: i18nT('common:code_error.error_code.502'),
|
||||
503: i18nT('common:code_error.error_code.503'),
|
||||
504: i18nT('common:code_error.error_code.504')
|
||||
};
|
||||
|
||||
export const TOKEN_ERROR_CODE: Record<number, string> = {
|
||||
403: '登录状态无效,请重新登录'
|
||||
403: i18nT('common:code_error.token_error_code.403')
|
||||
};
|
||||
|
||||
export const proxyError: Record<string, boolean> = {
|
||||
@@ -63,32 +64,31 @@ export const ERROR_RESPONSE: Record<
|
||||
[ERROR_ENUM.unAuthorization]: {
|
||||
code: 403,
|
||||
statusText: ERROR_ENUM.unAuthorization,
|
||||
message: '凭证错误',
|
||||
message: i18nT('common:code_error.error_message.403'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.insufficientQuota]: {
|
||||
code: 510,
|
||||
statusText: ERROR_ENUM.insufficientQuota,
|
||||
message: '账号余额不足',
|
||||
message: i18nT('common:code_error.error_message.510'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthModel]: {
|
||||
code: 511,
|
||||
statusText: ERROR_ENUM.unAuthModel,
|
||||
message: '无权操作该模型',
|
||||
message: i18nT('common:code_error.error_message.511'),
|
||||
data: null
|
||||
},
|
||||
|
||||
[ERROR_ENUM.unAuthFile]: {
|
||||
code: 513,
|
||||
statusText: ERROR_ENUM.unAuthFile,
|
||||
message: '无权阅读该文件',
|
||||
message: i18nT('common:code_error.error_message.513'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthApiKey]: {
|
||||
code: 514,
|
||||
statusText: ERROR_ENUM.unAuthApiKey,
|
||||
message: 'Api Key 不合法',
|
||||
message: i18nT('common:code_error.error_message.514'),
|
||||
data: null
|
||||
},
|
||||
...appErr,
|
||||
|
Reference in New Issue
Block a user