feat(i18n): complete internationalization for usage query feature

Fully internationalized the usage query feature to support both Chinese and English.

Frontend changes:
- Refactored UsageScriptModal to use i18n translation keys
- Replaced hardcoded Chinese template names with constants
- Implemented dynamic template generation with i18n support
- Internationalized all labels, placeholders, and code comments
- Added template name mapping for translation

Backend changes:
- Replaced all hardcoded Chinese error messages in usage_script.rs
- Converted 33 error instances from AppError::Message to AppError::localized
- Added bilingual error messages for runtime, parsing, HTTP, and validation errors

Translation updates:
- Added 11 new translation key pairs to zh.json and en.json
- Covered template names, field labels, placeholders, and code comments

Impact:
- 100% i18n coverage for usage query functionality
- All user-facing text and error messages now support language switching
- Better user experience for English-speaking users
This commit is contained in:
Jason
2025-11-05 00:07:54 +08:00
parent bafddb8e52
commit 720c4d9774
4 changed files with 91 additions and 59 deletions

View File

@@ -344,10 +344,21 @@
"title": "Configure Usage Query",
"enableUsageQuery": "Enable usage query",
"presetTemplate": "Preset template",
"templateCustom": "Custom",
"templateGeneral": "General",
"templateNewAPI": "NewAPI",
"accessToken": "Access Token",
"accessTokenPlaceholder": "Generate in 'Security Settings'",
"userId": "User ID",
"userIdPlaceholder": "e.g., 114514",
"defaultPlan": "Default Plan",
"queryFailedMessage": "Query failed",
"queryScript": "Query script (JavaScript)",
"timeoutSeconds": "Timeout (seconds)",
"scriptHelp": "Script writing instructions:",
"configFormat": "Configuration format:",
"commentOptional": "optional",
"commentResponseIsJson": "response is the JSON data returned by the API",
"extractorFormat": "Extractor return format (all fields optional):",
"tips": "💡 Tips:",
"testing": "Testing...",