From f95c6e63fb6678c40ae53483c4bfa04a7c0a26d9 Mon Sep 17 00:00:00 2001 From: Jerry <89069957+Jerry23011@users.noreply.github.com> Date: Wed, 29 Nov 2023 00:15:36 -0800 Subject: [PATCH] perf: optimize and localize error handling in unsupported languages --- Easydict/Feature/Service/Tencent/TencentService.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Easydict/Feature/Service/Tencent/TencentService.swift b/Easydict/Feature/Service/Tencent/TencentService.swift index 5589b63e2..44fc2a27e 100644 --- a/Easydict/Feature/Service/Tencent/TencentService.swift +++ b/Easydict/Feature/Service/Tencent/TencentService.swift @@ -77,10 +77,11 @@ public final class TencentService: QueryService { if prehandleQueryTextLanguage(text, autoConvertChineseText: false, from: from, to: to, completion: completion) { return } - let transType = TencentTranslateType.type(from: from, to: to) + let transType = TencentTranslateType.transType(from: from, to: to) guard transType != .unsupported else { result.errorType = .unsupportedLanguage - result.errorMessage = "不支持的翻译类型: \(from.rawValue) --> \(to.rawValue)" + let unsupportedType = NSLocalizedString("unsupported_translation_type", comment: "") + result.errorMessage = "\(unsupportedType): \(from.rawValue) --> \(to.rawValue)" completion(result, nil) return }