From 1daf0497370902afe1cbc3f697a363995c436534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Thu, 28 May 2026 19:27:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E7=BF=BB=E8=AF=91=EF=BC=8C=E4=BB=85=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除 public/_locales/en/ 目录,清理 chromeI18n.ts 中未使用的语言切换相关导出。 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- public/_locales/en/messages.json | 1290 ------------------------------ utils/chromeI18n.ts | 23 +- vitest.setup.ts | 10 +- 3 files changed, 4 insertions(+), 1319 deletions(-) delete mode 100644 public/_locales/en/messages.json diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json deleted file mode 100644 index b45c9fe..0000000 --- a/public/_locales/en/messages.json +++ /dev/null @@ -1,1290 +0,0 @@ -{ - "appName": { - "message": "Testing Tools", - "description": "Translation key: appName" - }, - "buttons_save": { - "message": "Save", - "description": "Translation key: buttons_save" - }, - "buttons_cancel": { - "message": "Cancel", - "description": "Translation key: buttons_cancel" - }, - "buttons_confirm": { - "message": "Confirm", - "description": "Translation key: buttons_confirm" - }, - "buttons_copy": { - "message": "Copy", - "description": "Translation key: buttons_copy" - }, - "buttons_clear": { - "message": "Clear", - "description": "Translation key: buttons_clear" - }, - "buttons_refresh": { - "message": "Refresh", - "description": "Translation key: buttons_refresh" - }, - "buttons_toggleLanguage": { - "message": "Switch Language", - "description": "Translation key: buttons_toggleLanguage" - }, - "buttons_toggleTheme": { - "message": "Toggle theme", - "description": "Translation key: buttons_toggleTheme" - }, - "buttons_themeMode_light": { - "message": "Switch to dark mode", - "description": "Translation key: buttons_themeMode_light" - }, - "buttons_themeMode_dark": { - "message": "Switch to system mode", - "description": "Translation key: buttons_themeMode_dark" - }, - "buttons_themeMode_system": { - "message": "Switch to light mode", - "description": "Translation key: buttons_themeMode_system" - }, - "buttons_search": { - "message": "Search tools...", - "description": "Translation key: buttons_search" - }, - "buttons_back": { - "message": "Back", - "description": "Translation key: buttons_back" - }, - "buttons_clearSearch": { - "message": "Clear search", - "description": "Translation key: buttons_clearSearch" - }, - "buttons_recentSearch": { - "message": "Recent search", - "description": "Translation key: buttons_recentSearch" - }, - "buttons_noResults": { - "message": "No tools found", - "description": "Translation key: buttons_noResults" - }, - "buttons_openInTab": { - "message": "Open in tab", - "description": "Translation key: buttons_openInTab" - }, - "buttons_settings": { - "message": "Settings", - "description": "Translation key: buttons_settings" - }, - "messages_copySuccess": { - "message": "Copied to clipboard", - "description": "Translation key: messages_copySuccess" - }, - "messages_copyError": { - "message": "Copy failed", - "description": "Translation key: messages_copyError" - }, - "messages_copyEmpty": { - "message": "Nothing to copy", - "description": "Translation key: messages_copyEmpty" - }, - "errorBoundary_title": { - "message": "Oops, something went wrong", - "description": "Translation key: errorBoundary_title" - }, - "errorBoundary_description": { - "message": "The app encountered an unexpected error. You can try refreshing the page or resetting the app.", - "description": "Translation key: errorBoundary_description" - }, - "errorBoundary_refresh": { - "message": "Refresh App", - "description": "Translation key: errorBoundary_refresh" - }, - "errorBoundary_retry": { - "message": "Retry", - "description": "Translation key: errorBoundary_retry" - }, - "pageErrorBoundary_title": { - "message": "This feature has encountered an error", - "description": "Translation key: pageErrorBoundary_title" - }, - "pageErrorBoundary_description": { - "message": "An internal script error occurred while loading or rendering this page. You can try again or switch to another tool from the navigation menu.", - "description": "Translation key: pageErrorBoundary_description" - }, - "router_notFound": { - "message": "Page Not Found", - "description": "Translation key: router_notFound" - }, - "router_notFoundDescription": { - "message": "This feature is not available or has been removed in the current runtime ({{entryPointType}}).", - "description": "Translation key: router_notFoundDescription" - }, - "textInputArea_clear": { - "message": "Clear", - "description": "Translation key: textInputArea_clear" - }, - "textInputArea_copyContent": { - "message": "Copy content", - "description": "Translation key: textInputArea_copyContent" - }, - "textInputArea_cleared": { - "message": "Cleared", - "description": "Translation key: textInputArea_cleared" - }, - "textInputArea_placeholder": { - "message": "placeholder text", - "description": "Translation key: textInputArea_placeholder" - }, - "dashboard_title": { - "message": "Dashboard", - "description": "Translation key: dashboard_title" - }, - "timestamp_title": { - "message": "Timestamp", - "description": "Translation key: timestamp_title" - }, - "timestamp_description": { - "message": "Unix millisecond conversion and formatting", - "description": "Translation key: timestamp_description" - }, - "storageCleaner_title": { - "message": "Storage Cleaner", - "description": "Translation key: storageCleaner_title" - }, - "storageCleaner_description": { - "message": "Clean cache, cookies, and local storage", - "description": "Translation key: storageCleaner_description" - }, - "qrCode_title": { - "message": "QR Code Tools", - "description": "Translation key: qrCode_title" - }, - "qrCode_description": { - "message": "Generate QR code for the selected URL", - "description": "Translation key: qrCode_description" - }, - "textStatistics_title": { - "message": "Text Statistics", - "description": "Translation key: textStatistics_title" - }, - "textStatistics_description": { - "message": "Real-time analysis of text characters, words, and bytes", - "description": "Translation key: textStatistics_description" - }, - "jwt_title": { - "message": "JWT Parser", - "description": "Translation key: jwt_title" - }, - "jwt_description": { - "message": "JSON Web Token decoding and viewing", - "description": "Translation key: jwt_description" - }, - "jsonDiff_title": { - "message": "JSON Tools", - "description": "Translation key: jsonDiff_title" - }, - "jsonDiff_description": { - "message": "Diff, format, YAML/TOML conversion, and minify", - "description": "Translation key: jsonDiff_description" - }, - "base64Converter_title": { - "message": "Base64 Converter", - "description": "Translation key: base64Converter_title" - }, - "base64Converter_description": { - "message": "Encode text, files, and images to Base64", - "description": "Translation key: base64Converter_description" - }, - "markdownToHtml_title": { - "message": "Markdown to HTML", - "description": "Translation key: markdownToHtml_title" - }, - "markdownToHtml_description": { - "message": "Real-time Markdown conversion and HTML preview", - "description": "Translation key: markdownToHtml_description" - }, - "htmlToMarkdown_title": { - "message": "HTML to Markdown", - "description": "Translation key: htmlToMarkdown_title" - }, - "htmlToMarkdown_description": { - "message": "Real-time HTML conversion and Markdown preview", - "description": "Translation key: htmlToMarkdown_description" - }, - "rightClickRestorer_title": { - "message": "Right Click Restorer", - "description": "Translation key: rightClickRestorer_title" - }, - "rightClickRestorer_description": { - "message": "Detect and restore disabled browser right-click menus", - "description": "Translation key: rightClickRestorer_description" - }, - "base64Converter_pageTitle": { - "message": "Base64 Converter", - "description": "Translation key: base64Converter_pageTitle" - }, - "base64Converter_pageSubtitle": { - "message": "Encode and decode text, files, and images with Base64", - "description": "Translation key: base64Converter_pageSubtitle" - }, - "base64Converter_textMode": { - "message": "Text", - "description": "Translation key: base64Converter_textMode" - }, - "base64Converter_fileMode": { - "message": "File", - "description": "Translation key: base64Converter_fileMode" - }, - "base64Converter_imageMode": { - "message": "Image", - "description": "Translation key: base64Converter_imageMode" - }, - "base64Converter_encode": { - "message": "Encode", - "description": "Translation key: base64Converter_encode" - }, - "base64Converter_decode": { - "message": "Decode", - "description": "Translation key: base64Converter_decode" - }, - "base64Converter_clear": { - "message": "Clear", - "description": "Translation key: base64Converter_clear" - }, - "base64Converter_textInputPlaceholder": { - "message": "Enter text to encode to Base64...", - "description": "Translation key: base64Converter_textInputPlaceholder" - }, - "base64Converter_base64InputPlaceholder": { - "message": "Enter Base64 string to decode...", - "description": "Translation key: base64Converter_base64InputPlaceholder" - }, - "base64Converter_base64Output": { - "message": "Base64 Output", - "description": "Translation key: base64Converter_base64Output" - }, - "base64Converter_textOutput": { - "message": "Decoded Text Output", - "description": "Translation key: base64Converter_textOutput" - }, - "base64Converter_copyRaw": { - "message": "Copy Raw Base64", - "description": "Translation key: base64Converter_copyRaw" - }, - "base64Converter_copyDataUri": { - "message": "Copy Data URI", - "description": "Translation key: base64Converter_copyDataUri" - }, - "base64Converter_clickOrDropToFile": { - "message": "Click or drop a file here", - "description": "Translation key: base64Converter_clickOrDropToFile" - }, - "base64Converter_clickOrDropToImage": { - "message": "Click or drop an image here", - "description": "Translation key: base64Converter_clickOrDropToImage" - }, - "base64Converter_clickOrDropToReplace": { - "message": "Click or drop to replace the file", - "description": "Translation key: base64Converter_clickOrDropToReplace" - }, - "base64Converter_maxFileSize": { - "message": "Maximum file size: {{max}}", - "description": "Translation key: base64Converter_maxFileSize" - }, - "base64Converter_supportedFormats": { - "message": "Supports PNG, JPG, WEBP, GIF, BMP, SVG, etc.", - "description": "Translation key: base64Converter_supportedFormats" - }, - "base64Converter_fileSizeExceeded": { - "message": "File size exceeds the limit (max {{max}})", - "description": "Translation key: base64Converter_fileSizeExceeded" - }, - "base64Converter_unsupportedImageType": { - "message": "Unsupported image format", - "description": "Translation key: base64Converter_unsupportedImageType" - }, - "base64Converter_conversionFailed": { - "message": "Conversion failed", - "description": "Translation key: base64Converter_conversionFailed" - }, - "base64Converter_originalSize": { - "message": "Original Size", - "description": "Translation key: base64Converter_originalSize" - }, - "base64Converter_encodedSize": { - "message": "Encoded Size", - "description": "Translation key: base64Converter_encodedSize" - }, - "base64Converter_invalidBase64": { - "message": "Invalid Base64 string", - "description": "Translation key: base64Converter_invalidBase64" - }, - "base64Converter_binaryDataDetected": { - "message": "Input appears to be binary data (e.g. an image). Please switch to the Image tab.", - "description": "Translation key: base64Converter_binaryDataDetected" - }, - "base64Converter_imageDataUriHint": { - "message": "Detected an image data URI — please use the Image tab to decode it.", - "description": "Translation key: base64Converter_imageDataUriHint" - }, - "base64Converter_switchToImageMode": { - "message": "Switch to Image mode", - "description": "Translation key: base64Converter_switchToImageMode" - }, - "base64Converter_download": { - "message": "Download", - "description": "Translation key: base64Converter_download" - }, - "base64Converter_decodedFileName": { - "message": "Decoded file name", - "description": "Translation key: base64Converter_decodedFileName" - }, - "base64Converter_decodeBase64Placeholder": { - "message": "Enter Base64 or data URI to decode...", - "description": "Translation key: base64Converter_decodeBase64Placeholder" - }, - "base64Converter_decodedFileOutput": { - "message": "Decoded File", - "description": "Translation key: base64Converter_decodedFileOutput" - }, - "base64Converter_decodedImageOutput": { - "message": "Decoded Image", - "description": "Translation key: base64Converter_decodedImageOutput" - }, - "base64Converter_inferredMimeType": { - "message": "Inferred MIME type", - "description": "Translation key: base64Converter_inferredMimeType" - }, - "base64Converter_decodedSize": { - "message": "Decoded size", - "description": "Translation key: base64Converter_decodedSize" - }, - "htmlToMarkdown_pageTitle": { - "message": "HTML to Markdown", - "description": "Translation key: htmlToMarkdown_pageTitle" - }, - "htmlToMarkdown_pageSubtitle": { - "message": "Convert HTML to Markdown in real-time", - "description": "Translation key: htmlToMarkdown_pageSubtitle" - }, - "htmlToMarkdown_splitMode": { - "message": "Split", - "description": "Translation key: htmlToMarkdown_splitMode" - }, - "htmlToMarkdown_previewMode": { - "message": "Preview", - "description": "Translation key: htmlToMarkdown_previewMode" - }, - "htmlToMarkdown_markdownMode": { - "message": "Markdown", - "description": "Translation key: htmlToMarkdown_markdownMode" - }, - "htmlToMarkdown_clear": { - "message": "Clear", - "description": "Translation key: htmlToMarkdown_clear" - }, - "htmlToMarkdown_inputLabel": { - "message": "HTML Input", - "description": "Translation key: htmlToMarkdown_inputLabel" - }, - "htmlToMarkdown_previewLabel": { - "message": "Markdown Preview", - "description": "Translation key: htmlToMarkdown_previewLabel" - }, - "htmlToMarkdown_markdownOutputLabel": { - "message": "Markdown Output", - "description": "Translation key: htmlToMarkdown_markdownOutputLabel" - }, - "htmlToMarkdown_inputPlaceholder": { - "message": "Enter your HTML content here...", - "description": "Translation key: htmlToMarkdown_inputPlaceholder" - }, - "htmlToMarkdown_charCount": { - "message": "{{count}} chars", - "description": "Translation key: htmlToMarkdown_charCount" - }, - "htmlToMarkdown_copyMarkdown": { - "message": "Copy Markdown", - "description": "Translation key: htmlToMarkdown_copyMarkdown" - }, - "htmlToMarkdown_download": { - "message": "Download", - "description": "Translation key: htmlToMarkdown_download" - }, - "htmlToMarkdown_emptyHint": { - "message": "Enter HTML content to see the conversion result", - "description": "Translation key: htmlToMarkdown_emptyHint" - }, - "jsonDiff_pageTitle": { - "message": "JSON Diff", - "description": "Translation key: jsonDiff_pageTitle" - }, - "jsonDiff_pageSubtitle": { - "message": "Compare differences between two JSON values", - "description": "Translation key: jsonDiff_pageSubtitle" - }, - "jsonDiff_leftPlaceholder": { - "message": "Enter the original JSON...", - "description": "Translation key: jsonDiff_leftPlaceholder" - }, - "jsonDiff_rightPlaceholder": { - "message": "Enter the target JSON...", - "description": "Translation key: jsonDiff_rightPlaceholder" - }, - "jsonDiff_leftLabel": { - "message": "Original JSON", - "description": "Translation key: jsonDiff_leftLabel" - }, - "jsonDiff_rightLabel": { - "message": "Target JSON", - "description": "Translation key: jsonDiff_rightLabel" - }, - "jsonDiff_compareButton": { - "message": "Compare", - "description": "Translation key: jsonDiff_compareButton" - }, - "jsonDiff_clearButton": { - "message": "Clear", - "description": "Translation key: jsonDiff_clearButton" - }, - "jsonDiff_sideBySideMode": { - "message": "Side by side", - "description": "Translation key: jsonDiff_sideBySideMode" - }, - "jsonDiff_unifiedMode": { - "message": "Unified", - "description": "Translation key: jsonDiff_unifiedMode" - }, - "jsonDiff_previousDiff": { - "message": "Previous", - "description": "Translation key: jsonDiff_previousDiff" - }, - "jsonDiff_nextDiff": { - "message": "Next", - "description": "Translation key: jsonDiff_nextDiff" - }, - "jsonDiff_noDiffs": { - "message": "No differences", - "description": "Translation key: jsonDiff_noDiffs" - }, - "jsonDiff_diffCount": { - "message": "{{count}} differences", - "description": "Translation key: jsonDiff_diffCount" - }, - "jsonDiff_invalidJson": { - "message": "Invalid JSON format", - "description": "Translation key: jsonDiff_invalidJson" - }, - "jsonDiff_emptyHint": { - "message": "Enter JSON on both sides and click Compare", - "description": "Translation key: jsonDiff_emptyHint" - }, - "jsonDiff_fixErrorHint": { - "message": "Fix the JSON syntax errors above to enable live comparison", - "description": "Translation key: jsonDiff_fixErrorHint" - }, - "jsonDiff_added": { - "message": "Added", - "description": "Translation key: jsonDiff_added" - }, - "jsonDiff_removed": { - "message": "Removed", - "description": "Translation key: jsonDiff_removed" - }, - "jsonDiff_modified": { - "message": "Modified", - "description": "Translation key: jsonDiff_modified" - }, - "jsonFormat_formatTitle": { - "message": "JSON Formatter", - "description": "Translation key: jsonFormat_formatTitle" - }, - "jsonFormat_formatSubtitle": { - "message": "Beautify and format JSON data", - "description": "Translation key: jsonFormat_formatSubtitle" - }, - "jsonFormat_inputPlaceholder": { - "message": "Enter JSON to format...", - "description": "Translation key: jsonFormat_inputPlaceholder" - }, - "jsonFormat_formatButton": { - "message": "Format", - "description": "Translation key: jsonFormat_formatButton" - }, - "jsonFormat_clearButton": { - "message": "Clear", - "description": "Translation key: jsonFormat_clearButton" - }, - "jsonFormat_sortKeys": { - "message": "Sort Keys", - "description": "Translation key: jsonFormat_sortKeys" - }, - "jsonFormat_sortKeysTooltip": { - "message": "Sort JSON object keys in alphabetical order", - "description": "Translation key: jsonFormat_sortKeysTooltip" - }, - "jsonFormat_indentSize": { - "message": "Indent", - "description": "Translation key: jsonFormat_indentSize" - }, - "jsonFormat_indentSpaces": { - "message": "{{count}} spaces", - "description": "Translation key: jsonFormat_indentSpaces" - }, - "jsonFormat_outputLabel": { - "message": "Formatted Result", - "description": "Translation key: jsonFormat_outputLabel" - }, - "jsonFormat_copySuccess": { - "message": "Copied", - "description": "Translation key: jsonFormat_copySuccess" - }, - "jsonFormat_copyFail": { - "message": "Copy failed", - "description": "Translation key: jsonFormat_copyFail" - }, - "jsonFormat_noContent": { - "message": "Nothing to copy", - "description": "Translation key: jsonFormat_noContent" - }, - "jsonFormat_invalidJson": { - "message": "Invalid JSON format", - "description": "Translation key: jsonFormat_invalidJson" - }, - "jsonFormat_emptyHint": { - "message": "Enter JSON and click Format", - "description": "Translation key: jsonFormat_emptyHint" - }, - "jsonFormat_fixErrorHint": { - "message": "Fix the JSON syntax errors above to enable live formatting", - "description": "Translation key: jsonFormat_fixErrorHint" - }, - "jsonFormat_originalSize": { - "message": "Original size", - "description": "Translation key: jsonFormat_originalSize" - }, - "jsonFormat_formattedSize": { - "message": "Formatted size", - "description": "Translation key: jsonFormat_formattedSize" - }, - "jsonFormat_diffMode": { - "message": "Diff", - "description": "Translation key: jsonFormat_diffMode" - }, - "jsonFormat_formatMode": { - "message": "Format", - "description": "Translation key: jsonFormat_formatMode" - }, - "jsonFormat_yamlMode": { - "message": "YAML", - "description": "Translation key: jsonFormat_yamlMode" - }, - "jsonFormat_tomlMode": { - "message": "TOML", - "description": "Translation key: jsonFormat_tomlMode" - }, - "jsonFormat_minifyMode": { - "message": "Minify", - "description": "Translation key: jsonFormat_minifyMode" - }, - "jsonFormat_yamlTitle": { - "message": "JSON to YAML", - "description": "Translation key: jsonFormat_yamlTitle" - }, - "jsonFormat_yamlSubtitle": { - "message": "Convert JSON data to YAML format", - "description": "Translation key: jsonFormat_yamlSubtitle" - }, - "jsonFormat_yamlModeInputPlaceholder": { - "message": "Enter JSON to convert...", - "description": "Translation key: jsonFormat_yamlModeInputPlaceholder" - }, - "jsonFormat_yamlModeOutputLabel": { - "message": "YAML Result", - "description": "Translation key: jsonFormat_yamlModeOutputLabel" - }, - "jsonFormat_yamlModeEmptyHint": { - "message": "Enter JSON and click Convert", - "description": "Translation key: jsonFormat_yamlModeEmptyHint" - }, - "jsonFormat_convertButton": { - "message": "Convert", - "description": "Translation key: jsonFormat_convertButton" - }, - "jsonFormat_tomlTitle": { - "message": "JSON to TOML", - "description": "Translation key: jsonFormat_tomlTitle" - }, - "jsonFormat_tomlSubtitle": { - "message": "Convert JSON data to TOML format", - "description": "Translation key: jsonFormat_tomlSubtitle" - }, - "jsonFormat_tomlModeInputPlaceholder": { - "message": "Enter JSON to convert...", - "description": "Translation key: jsonFormat_tomlModeInputPlaceholder" - }, - "jsonFormat_tomlModeOutputLabel": { - "message": "TOML Result", - "description": "Translation key: jsonFormat_tomlModeOutputLabel" - }, - "jsonFormat_tomlModeEmptyHint": { - "message": "Enter JSON and click Convert", - "description": "Translation key: jsonFormat_tomlModeEmptyHint" - }, - "jsonFormat_minifyTitle": { - "message": "JSON Minifier", - "description": "Translation key: jsonFormat_minifyTitle" - }, - "jsonFormat_minifySubtitle": { - "message": "Compress JSON into a compact single-line format", - "description": "Translation key: jsonFormat_minifySubtitle" - }, - "jsonFormat_minifyModeInputPlaceholder": { - "message": "Enter JSON to minify...", - "description": "Translation key: jsonFormat_minifyModeInputPlaceholder" - }, - "jsonFormat_minifyModeOutputLabel": { - "message": "Minified Result", - "description": "Translation key: jsonFormat_minifyModeOutputLabel" - }, - "jsonFormat_minifyModeEmptyHint": { - "message": "Enter JSON and click Minify", - "description": "Translation key: jsonFormat_minifyModeEmptyHint" - }, - "jsonFormat_minifyButton": { - "message": "Minify", - "description": "Translation key: jsonFormat_minifyButton" - }, - "jwt_pageTitle": { - "message": "JWT Parser", - "description": "Translation key: jwt_pageTitle" - }, - "jwt_pageSubtitle": { - "message": "JSON Web Token decoding and viewing", - "description": "Translation key: jwt_pageSubtitle" - }, - "jwt_placeholder": { - "message": "Paste Encoded JWT here...", - "description": "Translation key: jwt_placeholder" - }, - "jwt_headerTitle": { - "message": "HEADER: Algorithm & Token Type", - "description": "Translation key: jwt_headerTitle" - }, - "jwt_payloadTitle": { - "message": "PAYLOAD: Data", - "description": "Translation key: jwt_payloadTitle" - }, - "jwt_signatureTitle": { - "message": "Signature", - "description": "Translation key: jwt_signatureTitle" - }, - "jwt_noSignature": { - "message": "No Signature", - "description": "Translation key: jwt_noSignature" - }, - "jwt_invalidFormat": { - "message": "Unable to parse", - "description": "Translation key: jwt_invalidFormat" - }, - "jwt_errors_invalidBase64String": { - "message": "Invalid base64url string", - "description": "Translation key: jwt_errors_invalidBase64String" - }, - "jwt_errors_failedToDecode": { - "message": "Failed to decode base64url: ", - "description": "Translation key: jwt_errors_failedToDecode" - }, - "jwt_errors_invalidFormat": { - "message": "Invalid JWT format: expected 3 parts separated by .", - "description": "Translation key: jwt_errors_invalidFormat" - }, - "jwt_errors_parseHeaderFailed": { - "message": "Failed to parse Header: ", - "description": "Translation key: jwt_errors_parseHeaderFailed" - }, - "jwt_errors_parsePayloadFailed": { - "message": "Failed to parse Payload: ", - "description": "Translation key: jwt_errors_parsePayloadFailed" - }, - "markdownToHtml_pageTitle": { - "message": "Markdown to HTML", - "description": "Translation key: markdownToHtml_pageTitle" - }, - "markdownToHtml_pageSubtitle": { - "message": "Convert Markdown to HTML in real-time with preview", - "description": "Translation key: markdownToHtml_pageSubtitle" - }, - "markdownToHtml_splitMode": { - "message": "Split", - "description": "Translation key: markdownToHtml_splitMode" - }, - "markdownToHtml_previewMode": { - "message": "Preview", - "description": "Translation key: markdownToHtml_previewMode" - }, - "markdownToHtml_htmlMode": { - "message": "HTML", - "description": "Translation key: markdownToHtml_htmlMode" - }, - "markdownToHtml_clear": { - "message": "Clear", - "description": "Translation key: markdownToHtml_clear" - }, - "markdownToHtml_print": { - "message": "Print", - "description": "Translation key: markdownToHtml_print" - }, - "markdownToHtml_download": { - "message": "Download", - "description": "Translation key: markdownToHtml_download" - }, - "markdownToHtml_inputLabel": { - "message": "Markdown Input", - "description": "Translation key: markdownToHtml_inputLabel" - }, - "markdownToHtml_previewLabel": { - "message": "Live Preview", - "description": "Translation key: markdownToHtml_previewLabel" - }, - "markdownToHtml_htmlOutputLabel": { - "message": "HTML Output", - "description": "Translation key: markdownToHtml_htmlOutputLabel" - }, - "markdownToHtml_inputPlaceholder": { - "message": "Enter your Markdown content here...", - "description": "Translation key: markdownToHtml_inputPlaceholder" - }, - "markdownToHtml_charCount": { - "message": "{{count}} chars", - "description": "Translation key: markdownToHtml_charCount" - }, - "markdownToHtml_copyHtml": { - "message": "Copy HTML", - "description": "Translation key: markdownToHtml_copyHtml" - }, - "markdownToHtml_downloadSuccess": { - "message": "File downloaded successfully", - "description": "Translation key: markdownToHtml_downloadSuccess" - }, - "markdownToHtml_printSuccess": { - "message": "Print window opened", - "description": "Translation key: markdownToHtml_printSuccess" - }, - "qrCode_pageTitle": { - "message": "QR Code Tools", - "description": "Translation key: qrCode_pageTitle" - }, - "qrCode_pageSubtitle": { - "message": "Generate and parse QR codes", - "description": "Translation key: qrCode_pageSubtitle" - }, - "qrCode_generateMode": { - "message": "Generate QR Code", - "description": "Translation key: qrCode_generateMode" - }, - "qrCode_parseMode": { - "message": "Parse QR Code", - "description": "Translation key: qrCode_parseMode" - }, - "qrCode_urlToQr": { - "message": "Text to QR Code", - "description": "Translation key: qrCode_urlToQr" - }, - "qrCode_qrToUrl": { - "message": "QR Code to Text", - "description": "Translation key: qrCode_qrToUrl" - }, - "qrCode_urlInputLabel": { - "message": "Enter URL or Text", - "description": "Translation key: qrCode_urlInputLabel" - }, - "qrCode_urlInputPlaceholder": { - "message": "Enter URL or text content, QR code will be generated automatically", - "description": "Translation key: qrCode_urlInputPlaceholder" - }, - "qrCode_generateButton": { - "message": "Generate QR Code", - "description": "Translation key: qrCode_generateButton" - }, - "qrCode_generating": { - "message": "Generating...", - "description": "Translation key: qrCode_generating" - }, - "qrCode_qrCodeWillShow": { - "message": "QR code will be shown here", - "description": "Translation key: qrCode_qrCodeWillShow" - }, - "qrCode_downloadButton": { - "message": "Download QR Code", - "description": "Translation key: qrCode_downloadButton" - }, - "qrCode_copyQrButton": { - "message": "Copy QR Code Image", - "description": "Translation key: qrCode_copyQrButton" - }, - "qrCode_qrCodeSuccess": { - "message": "QR code generated successfully", - "description": "Translation key: qrCode_qrCodeSuccess" - }, - "qrCode_qrCodeDownloadSuccess": { - "message": "QR code downloaded successfully", - "description": "Translation key: qrCode_qrCodeDownloadSuccess" - }, - "qrCode_qrCodeCopySuccess": { - "message": "QR code copied to clipboard", - "description": "Translation key: qrCode_qrCodeCopySuccess" - }, - "qrCode_selectImage": { - "message": "Please select a QR code image", - "description": "Translation key: qrCode_selectImage" - }, - "qrCode_parseSuccess": { - "message": "QR code parsed successfully", - "description": "Translation key: qrCode_parseSuccess" - }, - "qrCode_noQrDetected": { - "message": "No QR code detected, please ensure the image is clear and contains a QR code", - "description": "Translation key: qrCode_noQrDetected" - }, - "qrCode_parseError": { - "message": "Failed to parse QR code, please try again", - "description": "Translation key: qrCode_parseError" - }, - "qrCode_generateError": { - "message": "Failed to generate QR code, please check the input", - "description": "Translation key: qrCode_generateError" - }, - "qrCode_copyError": { - "message": "Copy failed, please try again", - "description": "Translation key: qrCode_copyError" - }, - "qrCode_imagePasted": { - "message": "Image pasted, parsing...", - "description": "Translation key: qrCode_imagePasted" - }, - "qrCode_imagePasteError": { - "message": "Failed to paste image, please try again", - "description": "Translation key: qrCode_imagePasteError" - }, - "qrCode_imageCleared": { - "message": "Image cleared", - "description": "Translation key: qrCode_imageCleared" - }, - "qrCode_clickToUpload": { - "message": "Click, drag, or paste to upload QR code image", - "description": "Translation key: qrCode_clickToUpload" - }, - "qrCode_supportFormats": { - "message": "Supports PNG, JPG, WEBP, Base64 formats", - "description": "Translation key: qrCode_supportFormats" - }, - "qrCode_parseButton": { - "message": "Parse QR Code", - "description": "Translation key: qrCode_parseButton" - }, - "qrCode_parsing": { - "message": "Parsing...", - "description": "Translation key: qrCode_parsing" - }, - "qrCode_resultLabel": { - "message": "Parsing Result", - "description": "Translation key: qrCode_resultLabel" - }, - "qrCode_copyTooltip": { - "message": "Copy", - "description": "Translation key: qrCode_copyTooltip" - }, - "qrCode_enterUrlError": { - "message": "Please enter URL or text", - "description": "Translation key: qrCode_enterUrlError" - }, - "qrCode_clickToChange": { - "message": "Click to change image", - "description": "Translation key: qrCode_clickToChange" - }, - "qrCode_pasteHint": { - "message": "Supports Ctrl+V to paste images or Base64 strings", - "description": "Translation key: qrCode_pasteHint" - }, - "qrCode_autoGenerateHint": { - "message": "QR code will be generated automatically after input", - "description": "Translation key: qrCode_autoGenerateHint" - }, - "qrCode_autoParseHint": { - "message": "QR code will be parsed automatically after upload", - "description": "Translation key: qrCode_autoParseHint" - }, - "rightClickRestorer_loading": { - "message": "Loading...", - "description": "Translation key: rightClickRestorer_loading" - }, - "rightClickRestorer_currentDomain": { - "message": "Current Domain", - "description": "Translation key: rightClickRestorer_currentDomain" - }, - "rightClickRestorer_statusLocked": { - "message": "Locked", - "description": "Translation key: rightClickRestorer_statusLocked" - }, - "rightClickRestorer_statusUnlocked": { - "message": "Unlocked", - "description": "Translation key: rightClickRestorer_statusUnlocked" - }, - "rightClickRestorer_unsupported": { - "message": "Unsupported", - "description": "Translation key: rightClickRestorer_unsupported" - }, - "rightClickRestorer_unsupportedDesc": { - "message": "The current page is a browser internal or extension page. Right-click unlock is not available. Please switch to a regular webpage.", - "description": "Translation key: rightClickRestorer_unsupportedDesc" - }, - "rightClickRestorer_unlockDesc": { - "message": "Click the button below to temporarily unlock the right-click menu for the current website. You will need to unlock again after refreshing the page.", - "description": "Translation key: rightClickRestorer_unlockDesc" - }, - "rightClickRestorer_unlockBtn": { - "message": "Unlock Right Click", - "description": "Translation key: rightClickRestorer_unlockBtn" - }, - "rightClickRestorer_alreadyUnlocked": { - "message": "Right Click Unlocked", - "description": "Translation key: rightClickRestorer_alreadyUnlocked" - }, - "storageCleaner_pageTitle": { - "message": "Storage Cleaner", - "description": "Translation key: storageCleaner_pageTitle" - }, - "storageCleaner_pageSubtitle": { - "message": "Clear cache, cookies, and local storage", - "description": "Translation key: storageCleaner_pageSubtitle" - }, - "storageCleaner_loading": { - "message": "Loading...", - "description": "Translation key: storageCleaner_loading" - }, - "storageCleaner_initializing": { - "message": "Reading site data...", - "description": "Translation key: storageCleaner_initializing" - }, - "storageCleaner_occupied": { - "message": "Occupied {{size}}", - "description": "Translation key: storageCleaner_occupied" - }, - "storageCleaner_cleaning": { - "message": "Cleaning...", - "description": "Translation key: storageCleaner_cleaning" - }, - "storageCleaner_cleanNow": { - "message": "Clean Now", - "description": "Translation key: storageCleaner_cleanNow" - }, - "storageCleaner_autoRefresh": { - "message": "Auto refresh page after cleaning", - "description": "Translation key: storageCleaner_autoRefresh" - }, - "storageCleaner_selectAll": { - "message": "Select all items", - "description": "Translation key: storageCleaner_selectAll" - }, - "storageCleaner_cleanSuccess": { - "message": "Cleaning complete", - "description": "Translation key: storageCleaner_cleanSuccess" - }, - "storageCleaner_cleanError": { - "message": "Cleaning failed", - "description": "Translation key: storageCleaner_cleanError" - }, - "storageCleaner_noData": { - "message": "No data", - "description": "Translation key: storageCleaner_noData" - }, - "storageCleaner_countUnit": { - "message": "items", - "description": "Translation key: storageCleaner_countUnit" - }, - "storageCleaner_errorNoTab": { - "message": "Unable to get current tab", - "description": "Translation key: storageCleaner_errorNoTab" - }, - "storageCleaner_errorRestricted": { - "message": "Storage cleaning is not supported on this page", - "description": "Translation key: storageCleaner_errorRestricted" - }, - "storageCleaner_cleanSuccessReload": { - "message": "Cleaning successful, reloading page...", - "description": "Translation key: storageCleaner_cleanSuccessReload" - }, - "storageCleaner_errorStandardOnly": { - "message": "Storage cleaning only works on standard web pages", - "description": "Translation key: storageCleaner_errorStandardOnly" - }, - "storageCleaner_confirmTitle": { - "message": "Confirm Clear Data?", - "description": "Translation key: storageCleaner_confirmTitle" - }, - "storageCleaner_confirmDesc": { - "message": "You are about to permanently delete the following selected storage items from the current page.", - "description": "Translation key: storageCleaner_confirmDesc" - }, - "storageCleaner_irreversible": { - "message": "This action is irreversible", - "description": "Translation key: storageCleaner_irreversible" - }, - "storageCleaner_confirmAction": { - "message": "Confirm Clear", - "description": "Translation key: storageCleaner_confirmAction" - }, - "storageCleaner_cleanedSummary": { - "message": "Cleaned {{items}}", - "description": "Translation key: storageCleaner_cleanedSummary" - }, - "storageCleaner_noDataToClean": { - "message": "No storage data found to clean", - "description": "Translation key: storageCleaner_noDataToClean" - }, - "storageCleaner_partialFailure": { - "message": "Some items failed to clean", - "description": "Translation key: storageCleaner_partialFailure" - }, - "storageCleaner_options_localStorage": { - "message": "Local Storage", - "description": "Translation key: storageCleaner_options_localStorage" - }, - "storageCleaner_options_sessionStorage": { - "message": "Session Storage", - "description": "Translation key: storageCleaner_options_sessionStorage" - }, - "storageCleaner_options_indexedDB": { - "message": "IndexedDB", - "description": "Translation key: storageCleaner_options_indexedDB" - }, - "storageCleaner_options_cookies": { - "message": "Cookies", - "description": "Translation key: storageCleaner_options_cookies" - }, - "storageCleaner_options_cacheStorage": { - "message": "Cache Storage", - "description": "Translation key: storageCleaner_options_cacheStorage" - }, - "storageCleaner_options_serviceWorkers": { - "message": "Service Workers", - "description": "Translation key: storageCleaner_options_serviceWorkers" - }, - "textStatistics_pageTitle": { - "message": "Text Statistics", - "description": "Translation key: textStatistics_pageTitle" - }, - "textStatistics_pageSubtitle": { - "message": "Real-time analysis of characters, words, lines, and byte size", - "description": "Translation key: textStatistics_pageSubtitle" - }, - "textStatistics_placeholder": { - "message": "Type or paste text here...", - "description": "Translation key: textStatistics_placeholder" - }, - "textStatistics_characters": { - "message": "Characters", - "description": "Translation key: textStatistics_characters" - }, - "textStatistics_words": { - "message": "Words", - "description": "Translation key: textStatistics_words" - }, - "textStatistics_lines": { - "message": "Lines", - "description": "Translation key: textStatistics_lines" - }, - "textStatistics_bytes": { - "message": "Byte Size", - "description": "Translation key: textStatistics_bytes" - }, - "timestamp_pageTitle": { - "message": "Timestamp Conversion", - "description": "Translation key: timestamp_pageTitle" - }, - "timestamp_pageSubtitle": { - "message": "Unix millisecond conversion and formatting", - "description": "Translation key: timestamp_pageSubtitle" - }, - "timestamp_tsToDate": { - "message": "Timestamp → Date", - "description": "Translation key: timestamp_tsToDate" - }, - "timestamp_dateToTs": { - "message": "Date → Timestamp", - "description": "Translation key: timestamp_dateToTs" - }, - "timestamp_placeholderTs": { - "message": "Enter timestamp...", - "description": "Translation key: timestamp_placeholderTs" - }, - "timestamp_placeholderDate": { - "message": "YYYY-MM-DD HH:mm:ss", - "description": "Translation key: timestamp_placeholderDate" - }, - "timestamp_unitMs": { - "message": "Millisecond (ms)", - "description": "Translation key: timestamp_unitMs" - }, - "timestamp_unitS": { - "message": "Second (s)", - "description": "Translation key: timestamp_unitS" - }, - "timestamp_convertButton": { - "message": "Convert Now", - "description": "Translation key: timestamp_convertButton" - }, - "timestamp_currentTs": { - "message": "Current Timestamp", - "description": "Translation key: timestamp_currentTs" - }, - "timestamp_useNowTooltip": { - "message": "Use this value", - "description": "Translation key: timestamp_useNowTooltip" - }, - "timestamp_copyTsTooltip": { - "message": "Copy timestamp", - "description": "Translation key: timestamp_copyTsTooltip" - }, - "timestamp_usedSuccess": { - "message": "Using current timestamp", - "description": "Translation key: timestamp_usedSuccess" - }, - "timestamp_resultLabel": { - "message": "Conversion Result", - "description": "Translation key: timestamp_resultLabel" - }, - "timestamp_copyResultTooltip": { - "message": "Copy result", - "description": "Translation key: timestamp_copyResultTooltip" - }, - "timestamp_relativeTime": { - "message": "Relative Time", - "description": "Translation key: timestamp_relativeTime" - }, - "timestamp_iso8601": { - "message": "ISO 8601", - "description": "Translation key: timestamp_iso8601" - }, - "timestamp_utcTime": { - "message": "UTC Time", - "description": "Translation key: timestamp_utcTime" - }, - "timestamp_copyTooltip": { - "message": "Copy", - "description": "Translation key: timestamp_copyTooltip" - }, - "timestamp_resultEmpty": { - "message": "Enter a value and click convert", - "description": "Translation key: timestamp_resultEmpty" - }, - "timestamp_errors_invalidNumber": { - "message": "Invalid number", - "description": "Translation key: timestamp_errors_invalidNumber" - }, - "timestamp_errors_invalidTimestamp": { - "message": "Invalid timestamp", - "description": "Translation key: timestamp_errors_invalidTimestamp" - }, - "timestamp_errors_invalidFormat": { - "message": "Format error", - "description": "Translation key: timestamp_errors_invalidFormat" - }, - "common_buttons_save": { - "message": "Save", - "description": "Translation key: buttons_save" - }, - "common_buttons_cancel": { - "message": "Cancel", - "description": "Translation key: buttons_cancel" - }, - "common_buttons_confirm": { - "message": "Confirm", - "description": "Translation key: buttons_confirm" - }, - "common_buttons_copy": { - "message": "Copy", - "description": "Translation key: buttons_copy" - }, - "common_buttons_clear": { - "message": "Clear", - "description": "Translation key: buttons_clear" - }, - "common_buttons_refresh": { - "message": "Refresh", - "description": "Translation key: buttons_refresh" - }, - "common_buttons_toggleLanguage": { - "message": "Switch Language", - "description": "Translation key: buttons_toggleLanguage" - }, - "common_buttons_toggleTheme": { - "message": "Toggle theme", - "description": "Translation key: buttons_toggleTheme" - }, - "common_buttons_themeMode_light": { - "message": "Switch to dark mode", - "description": "Translation key: buttons_themeMode_light" - }, - "common_buttons_themeMode_dark": { - "message": "Switch to system mode", - "description": "Translation key: buttons_themeMode_dark" - }, - "common_buttons_themeMode_system": { - "message": "Switch to light mode", - "description": "Translation key: buttons_themeMode_system" - }, - "common_buttons_search": { - "message": "Search tools...", - "description": "Translation key: buttons_search" - }, - "common_buttons_back": { - "message": "Back", - "description": "Translation key: buttons_back" - }, - "common_buttons_clearSearch": { - "message": "Clear search", - "description": "Translation key: buttons_clearSearch" - }, - "common_buttons_recentSearch": { - "message": "Recent search", - "description": "Translation key: buttons_recentSearch" - }, - "common_buttons_noResults": { - "message": "No tools found", - "description": "Translation key: buttons_noResults" - }, - "common_buttons_openInTab": { - "message": "Open in tab", - "description": "Translation key: buttons_openInTab" - }, - "common_buttons_settings": { - "message": "Settings", - "description": "Translation key: buttons_settings" - }, - "common_errorBoundary_title": { - "message": "Oops, something went wrong", - "description": "Translation key: errorBoundary_title" - }, - "common_errorBoundary_description": { - "message": "The app encountered an unexpected error. You can try refreshing the page or resetting the app.", - "description": "Translation key: errorBoundary_description" - }, - "common_errorBoundary_refresh": { - "message": "Refresh App", - "description": "Translation key: errorBoundary_refresh" - }, - "common_errorBoundary_retry": { - "message": "Retry", - "description": "Translation key: errorBoundary_retry" - }, - "common_pageErrorBoundary_title": { - "message": "This feature has encountered an error", - "description": "Translation key: pageErrorBoundary_title" - }, - "common_pageErrorBoundary_description": { - "message": "An internal script error occurred while loading or rendering this page. You can try again or switch to another tool from the navigation menu.", - "description": "Translation key: pageErrorBoundary_description" - } -} diff --git a/utils/chromeI18n.ts b/utils/chromeI18n.ts index e40f6da..d275b01 100644 --- a/utils/chromeI18n.ts +++ b/utils/chromeI18n.ts @@ -18,27 +18,6 @@ export function getMessage(msgId: string, substitutions?: string[]): string { } } -/** - * 获取当前浏览器语言 - * @returns 语言代码(如 'zh', 'en') - */ -export function getLanguage(): string { - const lang = chrome.i18n.getUILanguage(); - return lang.toLowerCase().startsWith('zh') ? 'zh' : 'en'; -} - -/** - * 支持的语言列表 - */ -export const SUPPORTED_LANGUAGES: readonly ('zh' | 'en')[] = ['zh', 'en'] as const; - -/** - * 规范化语言代码 - */ -export function normalizeLanguage(lng: string): 'zh' | 'en' { - return lng.toLowerCase().startsWith('zh') ? 'zh' : 'en'; -} - /** * react-i18next 兼容的 Hook * 返回 t 函数和相关信息 @@ -82,7 +61,7 @@ export function useI18n(namespace?: string | string[]) { return { t, i18n: { - language: getLanguage(), + language: 'zh', changeLanguage: (_lng?: string) => { // chrome.i18n 无法动态切换语言,需要刷新页面 console.warn('[chrome.i18n] 无法动态切换语言,需要刷新页面'); diff --git a/vitest.setup.ts b/vitest.setup.ts index 638cd37..abe63e7 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -3,11 +3,9 @@ import { afterEach, beforeEach, vi } from 'vitest'; import React from 'react'; // Load actual zh translations for getMessage mock -// eslint-disable-next-line @typescript-eslint/no-require-imports -const zhMessages: Record< - string, - { message: string } -> = require('./public/_locales/zh/messages.json'); +const zhMessages: Record = + // eslint-disable-next-line @typescript-eslint/no-require-imports + require('./public/_locales/zh/messages.json'); vi.mock('@/utils/chromeI18n', () => ({ useI18n: (ns?: string | string[]) => ({ @@ -37,8 +35,6 @@ vi.mock('@/utils/chromeI18n', () => ({ }), getMessage: (msgId: string) => zhMessages[msgId]?.message ?? msgId, getLanguage: () => 'zh', - normalizeLanguage: (lng: string) => (lng.startsWith('zh') ? 'zh' : 'en'), - SUPPORTED_LANGUAGES: ['zh', 'en'], preloadNamespaces: vi.fn().mockResolvedValue(undefined), }));