fix(i18n): internationalize test script related error messages

Fixed 5 hardcoded Chinese error messages to support bilingual display:

Backend changes (services):
- provider.rs: Fixed 4 error messages:
  * Data format error when deserializing array (line 731)
  * Data format error when deserializing single object (line 738)
  * Regex initialization failure (line 1163)
  * App type not found (line 1191)
- speedtest.rs: Fixed 1 error message:
  * HTTP client creation failure (line 104)

All errors now use AppError::localized to provide both Chinese and English messages.

Impact:
- Users will now see properly localized error messages when testing usage scripts
- Error messages respect the application language setting
- Better user experience for English-speaking users
This commit is contained in:
Jason
2025-11-05 08:52:36 +08:00
parent 720c4d9774
commit f92dd4cc5a
2 changed files with 25 additions and 5 deletions

View File

@@ -101,7 +101,11 @@ impl SpeedtestService {
.redirect(reqwest::redirect::Policy::limited(5))
.user_agent("cc-switch-speedtest/1.0")
.build()
.map_err(|e| AppError::Message(format!("创建 HTTP 客户端失败: {e}")))
.map_err(|e| AppError::localized(
"speedtest.client_create_failed",
format!("创建 HTTP 客户端失败: {e}"),
format!("Failed to create HTTP client: {e}")
))
}
fn sanitize_timeout(timeout_secs: Option<u64>) -> u64 {