diff --git a/html/src/classes/apiRequestHandler.js b/html/src/classes/apiRequestHandler.js index c96be0bc..ae2ba731 100644 --- a/html/src/classes/apiRequestHandler.js +++ b/html/src/classes/apiRequestHandler.js @@ -33,7 +33,7 @@ export default class extends baseClass { if (lastRun >= Date.now() - 900000) { // 15mins throw new Error( - `Bailing request due to recent 404/403, ${endpoint}` + `${$t('api.error.message.403_404_bailing_request')}, ${endpoint}` ); } this.failedGetRequests.delete(endpoint); @@ -87,7 +87,11 @@ export default class extends baseClass { return response; } catch (e) {} if (response.status === 200) { - this.$throw(0, 'Invalid JSON response', endpoint); + this.$throw( + 0, + $t('api.error.message.invalid_json_response'), + endpoint + ); } if ( response.status === 429 && @@ -131,7 +135,9 @@ export default class extends baseClass { data.error.message === '"Missing Credentials"' ) { this.$emit('AUTOLOGIN'); - throw new Error('401: Missing Credentials'); + throw new Error( + `401 ${$t('api.error.message.missing_credentials')}` + ); } if ( status === 401 && @@ -142,15 +148,15 @@ export default class extends baseClass { if (!$app.twoFactorAuthDialogVisible) { $app.API.getCurrentUser(); } - throw new Error('401: Unauthorized'); + throw new Error(`401 ${$t('api.status_code.401')}`); } if (status === 403 && endpoint === 'config') { $app.$alert( - 'VRChat currently blocks most VPNs. Please disable any connected VPNs and try again.', - 'Login Error 403' + $t('api.error.message.vpn_in_use'), + `403 ${$t('api.error.message.login_error')}` ); this.logout(); - throw new Error(`403: ${endpoint}`); + throw new Error(`403 ${endpoint}`); } if ( init.method === 'GET' && @@ -159,7 +165,7 @@ export default class extends baseClass { ) { $app.$message({ message: $t( - 'message.api_headler.avatar_private_or_deleted' + 'api.error.message.avatar_private_or_deleted' ), type: 'error' }); @@ -238,18 +244,23 @@ export default class extends baseClass { API.$throw = function (code, error, endpoint) { var text = []; if (code > 0) { - var status = this.statusCodes[code]; + const status = this.statusCodes[code]; if (typeof status === 'undefined') { text.push(`${code}`); } else { - text.push(`${code} ${status}`); + const codeText = $t(`api.status_code.${code}`); + text.push(`${code} ${codeText}`); } } if (typeof error !== 'undefined') { - text.push(JSON.stringify(error)); + text.push( + `${$t('api.error.message.error_message')}${typeof error === 'string' ? error : JSON.stringify(error)}` + ); } if (typeof endpoint !== 'undefined') { - text.push(JSON.stringify(endpoint)); + text.push( + `${$t('api.error.message.endpoint')}"${typeof endpoint === 'string' ? endpoint : JSON.stringify(endpoint)}"` + ); } text = text.map((s) => $app.escapeTag(s)).join('
'); if (text.length) { diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index d22bdd96..916ba9c1 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -1842,5 +1842,92 @@ "cpu": "CPU:", "online": "Online:" } + }, + "api": { + "status_code": { + "100": "Continue", + "101": "Switching Protocols", + "102": "Processing", + "103": "Early Hints", + "200": "OK", + "201": "Created", + "202": "Accepted", + "203": "Non-Authoritative Information", + "204": "No Content", + "205": "Reset Content", + "206": "Partial Content", + "207": "Multi-Status", + "208": "Already Reported", + "226": "IM Used", + "300": "Multiple Choices", + "301": "Moved Permanently", + "302": "Found", + "303": "See Other", + "304": "Not Modified", + "305": "Use Proxy", + "306": "Switch Proxy", + "307": "Temporary Redirect", + "308": "Permanent Redirect", + "400": "Bad Request", + "401": "Unauthorized", + "402": "Payment Required", + "403": "Forbidden", + "404": "Not Found", + "405": "Method Not Allowed", + "406": "Not Acceptable", + "407": "Proxy Authentication Required", + "408": "Request Timeout", + "409": "Conflict", + "410": "Gone", + "411": "Length Required", + "412": "Precondition Failed", + "413": "Payload Too Large", + "414": "URI Too Long", + "415": "Unsupported Media Type", + "416": "Range Not Satisfiable", + "417": "Expectation Failed", + "418": "I'm a teapot", + "421": "Misdirected Request", + "422": "Unprocessable Entity", + "423": "Locked", + "424": "Failed Dependency", + "425": "Too Early", + "426": "Upgrade Required", + "428": "Precondition Required", + "429": "Too Many Requests", + "431": "Request Header Fields Too Large", + "451": "Unavailable For Legal Reasons", + "500": "Internal Server Error", + "501": "Not Implemented", + "502": "Bad Gateway", + "503": "Service Unavailable", + "504": "Gateway Timeout", + "505": "HTTP Version Not Supported", + "506": "Variant Also Negotiates", + "507": "Insufficient Storage", + "508": "Loop Detected", + "510": "Not Extended", + "511": "Network Authentication Required", + "520": "Web server returns an unknown error", + "521": "Web server is down", + "522": "Connection timed out", + "523": "Origin is unreachable", + "524": "A timeout occurred", + "525": "SSL handshake failed", + "526": "Invalid SSL certificate", + "527": "Railgun Listener to origin error" + }, + "error": { + "message": { + "error_message": "Error Message: ", + "endpoint": "Endpoint: ", + "missing_credentials": "Missing Credentials", + "avatar_private_or_deleted": "Avatar private or deleted", + "vpn_in_use": "VRChat currently blocks most VPNs. Please disable any connected VPNs and try again.", + "login_error": "Login Error", + "invalid_json_response": "Invalid JSON response", + "403_404_bailing_request": "Bailing request due to recent 404/403" + } + } } } \ No newline at end of file diff --git a/html/src/localization/ja/en.json b/html/src/localization/ja/en.json index f7b87a2d..127975b5 100644 --- a/html/src/localization/ja/en.json +++ b/html/src/localization/ja/en.json @@ -1830,5 +1830,92 @@ "cpu": "CPU:", "online": "オンライン:" } + }, + "api": { + "status_code": { + "100": "続行", + "101": "プロトコルの切り替え", + "102": "処理中", + "103": "早期ヒント", + "200": "成功", + "201": "作成された", + "202": "受け入れた", + "203": "非権威情報", + "204": "コンテンツなし", + "205": "コンテンツをリセット", + "206": "部分コンテンツ", + "207": "複数のステータス", + "208": "すでに報告済み", + "226": "IM使用中", + "300": "複数の選択肢", + "301": "恒久的に移動", + "302": "見つかった", + "303": "その他を参照", + "304": "未変更", + "305": "プロキシを使用", + "306": "プロキシを切り替え", + "307": "一時的なリダイレクト", + "308": "恒久的なリダイレクト", + "400": "不正なリクエスト", + "401": "未認証", + "402": "支払いが必要", + "403": "禁止", + "404": "見つかりません", + "405": "方法が許可されていない", + "406": "受け入れられない", + "407": "プロキシ認証が必要", + "408": "リクエストタイムアウト", + "409": "競合", + "410": "消えた", + "411": "長さが必要", + "412": "前提条件に失敗しました", + "413": "ペイロードが大きすぎます", + "414": "URIが長すぎます", + "415": "サポートされていないメディアタイプ", + "416": "範囲が満たされていない", + "417": "期待に失敗しました", + "418": "私はティーポットです", + "421": "誤ったリクエスト", + "422": "処理できないエンティティ", + "423": "ロックされた", + "424": "依存関係に失敗しました", + "425": "早すぎる", + "426": "アップグレードが必要です", + "428": "前提条件が必要です", + "429": "リクエストが多すぎます", + "431": "リクエストヘッダーフィールドが大きすぎます", + "451": "法的理由により利用できません", + "500": "内部サーバーエラー", + "501": "未実装", + "502": "不正なゲートウェイ", + "503": "サービス利用不可", + "504": "ゲートウェイタイムアウト", + "505": "HTTPバージョンがサポートされていません", + "506": "バリアントも交渉します", + "507": "ストレージ不足", + "508": "ループ検出", + "510": "拡張されていません", + "511": "ネットワーク認証が必要です", + "520": "Webサーバーが不明なエラーを返します", + "521": "Webサーバーがダウンしています", + "522": "接続がタイムアウトしました", + "523": "起源に到達できません", + "524": "タイムアウトが発生しました", + "525": "SSLハンドシェイクに失敗しました", + "526": "無効なSSL証明書", + "527": "Railgunリスナーからの起源エラー" + }, + "error": { + "message": { + "error_message": "エラーメッセージ:", + "endpoint": "エンドポイント:", + "missing_credentials": "認証情報不足", + "avatar_private_or_deleted": "アバターは非公開または削除されました", + "vpn_in_use": "VRChatは現在ほとんどのVPNをブロックしています。接続中のVPNを無効にして、もう一度お試しください。", + "login_error": "ログインエラー", + "invalid_json_response": "無効なJSONレスポンス", + "403_404_bailing_request": "最近の404/403エラーのため、リクエストを中止しました" + } + } } } \ No newline at end of file diff --git a/html/src/localization/zh-CN/en.json b/html/src/localization/zh-CN/en.json index d58272c9..cd98e892 100644 --- a/html/src/localization/zh-CN/en.json +++ b/html/src/localization/zh-CN/en.json @@ -1833,5 +1833,92 @@ "cpu": "CPU:", "online": "在线:" } + }, + "api": { + "status_code": { + "100": "继续", + "101": "切换协议", + "102": "处理中", + "103": "早期提示", + "200": "成功", + "201": "已创建", + "202": "已接受", + "203": "非权威信息", + "204": "无内容", + "205": "重置内容", + "206": "部分内容", + "207": "多状态", + "208": "已报告", + "226": "IM已使用", + "300": "多种选择", + "301": "永久移动", + "302": "找到", + "303": "参见其他", + "304": "未修改", + "305": "使用代理", + "306": "切换代理", + "307": "临时重定向", + "308": "永久重定向", + "400": "错误请求", + "401": "未授权", + "402": "需要付款", + "403": "禁止", + "404": "未找到", + "405": "方法不允许", + "406": "不可接受", + "407": "需要代理身份验证", + "408": "请求超时", + "409": "冲突", + "410": "已删除", + "411": "需要长度", + "412": "前提条件失败", + "413": "有效负载过大", + "414": "URI过长", + "415": "不支持的媒体类型", + "416": "范围不满足", + "417": "期望失败", + "418": "我是一个茶壶", + "421": "错误的请求", + "422": "不可处理的实体", + "423": "锁定", + "424": "依赖失败", + "425": "过早", + "426": "需要升级", + "428": "需要前提条件", + "429": "请求过多", + "431": "请求头字段太大", + "451": "因法律原因不可用", + "500": "内部服务器错误", + "501": "未实现", + "502": "错误网关", + "503": "服务不可用", + "504": "网关超时", + "505": "HTTP版本不支持", + "506": "变体也协商", + "507": "存储不足", + "508": "循环检测", + "510": "未扩展", + "511": "需要网络身份验证", + "520": "Web服务器返回未知错误", + "521": "Web服务器关闭", + "522": "连接超时", + "523": "源不可达", + "524": "超时发生", + "525": "SSL握手失败", + "526": "无效的SSL证书", + "527": "Railgun监听器到源错误" + }, + "error": { + "message": { + "error_message": "错误信息:", + "endpoint": "接口地址:", + "missing_credentials": "访问凭据缺失", + "avatar_private_or_deleted": "模型是私密的或已被删除", + "vpn_in_use": "VRChat 目前屏蔽了大多数的 VPN。请断开所有已连接的 VPN 后重试。", + "login_error": "登录失败", + "invalid_json_response": "无效的 JSON 响应", + "403_404_bailing_request": "由于最近出现 404/403 错误,请求已中止" + } + } } } \ No newline at end of file