Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
A1C1A10130ABCDEF00112233 /* ClaudeSSEParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C1A10030ABCDEF00112233 /* ClaudeSSEParserTests.swift */; };
A1C1A10430ABCDEF00112233 /* ClaudeSSEParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1C1A10330ABCDEF00112233 /* ClaudeSSEParser.swift */; };
A1D1807B2F8D100100B1C0D1 /* ThrottleGate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D1807A2F8D100100B1C0D1 /* ThrottleGate.swift */; };
A1D1807F2F8D100100B1C0D1 /* NetworkSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D1807F2F8D000100B1C0D1 /* NetworkSession.swift */; };
A1D1807E2F8D100100B1C0D1 /* ThrottleGateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1D1807D2F8D100100B1C0D1 /* ThrottleGateTests.swift */; };
A2016EDA90ED45B5B66FA986 /* AnalyticsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14921B68C1D645268F93668E /* AnalyticsService.swift */; };
A94F9CB9D704426DB91B25D3 /* DeviceSystemInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E54300FF4F544CC2A180FE53 /* DeviceSystemInfo.swift */; };
Expand Down Expand Up @@ -1197,6 +1198,7 @@
A1C1A10030ABCDEF00112233 /* ClaudeSSEParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaudeSSEParserTests.swift; sourceTree = "<group>"; };
A1C1A10330ABCDEF00112233 /* ClaudeSSEParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaudeSSEParser.swift; sourceTree = "<group>"; };
A1D1807A2F8D100100B1C0D1 /* ThrottleGate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThrottleGate.swift; sourceTree = "<group>"; };
A1D1807F2F8D000100B1C0D1 /* NetworkSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkSession.swift; sourceTree = "<group>"; };
A1D1807D2F8D100100B1C0D1 /* ThrottleGateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThrottleGateTests.swift; sourceTree = "<group>"; };
A230E9A2358C7FBC7FB26189 /* Pods-EasydictTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EasydictTests.debug.xcconfig"; path = "Target Support Files/Pods-EasydictTests/Pods-EasydictTests.debug.xcconfig"; sourceTree = "<group>"; };
A6C26D557A3746598059449DAD170FE1 /* OrderedDictionary+Variadic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "OrderedDictionary+Variadic.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3436,6 +3438,7 @@
EA9943E62B534D7C00EE7B97 /* Extensions */,
03538DF12D25AAD1005E56A8 /* CookieManager.swift */,
A1D1807A2F8D100100B1C0D1 /* ThrottleGate.swift */,
A1D1807F2F8D000100B1C0D1 /* NetworkSession.swift */,
03A3E1542BEBDB2000E7E210 /* Throttler.swift */,
);
path = Utility;
Expand Down Expand Up @@ -3996,6 +3999,7 @@
039CBE872D9AFBF3009A04DC /* ChineseGenreAnalyzer.swift in Sources */,
03BDA7C12A26DA280079D04F /* XPMArgumentParser.m in Sources */,
A1D1807B2F8D100100B1C0D1 /* ThrottleGate.swift in Sources */,
A1D1807F2F8D100100B1C0D1 /* NetworkSession.swift in Sources */,
03A3E1552BEBDB2000E7E210 /* Throttler.swift in Sources */,
03D9D6FF2D8C186F009E0CEC /* NSScreen+Extention.swift in Sources */,
03991166292A8A4400E1B06D /* EZTitleBarMoveView.m in Sources */,
Expand Down
112 changes: 112 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -7175,6 +7175,118 @@
}
}
},
"setting.advance.header.local_proxy" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Local Proxy"
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Lokálny proxy"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "本地代理"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "本地代理"
}
}
}
},
"setting.advance.http_proxy_url" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "HTTP Proxy URL"
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "HTTP Proxy URL"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "HTTP 代理地址"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "HTTP 代理地址"
}
}
}
},
"setting.advance.http_proxy_url_desc" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Supports http:// and socks5:// schemes"
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Podporuje schémy http:// a socks5://"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "支持 http:// 和 socks5:// 格式"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "支持 http:// 和 socks5:// 格式"
}
}
}
},
"setting.advance.http_proxy_url_footer" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Routes all translation requests through the specified proxy. Leave empty to use system default networking."
}
},
"sk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Presmeruje všetky prekladové požiadavky cez zadaný proxy. Nechajte prázdne pre predvolené sieťové nastavenia."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "所有翻译服务请求将通过指定的代理发出。留空则使用系统默认网络设置。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "所有翻譯服務請求將透過指定的代理發出。留空則使用系統預設網路設定。"
}
}
}
},
"setting.advance.header.ocr_settings" : {
"localizations" : {
"en" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ extension Defaults.Keys {
static var enableHTTPServer = Key<Bool>("enableHTTPServer", default: false)
static var httpPort = Key<String>("httpPort", default: "8080")

/// Local HTTP/SOCKS proxy URL used for all translation service requests.
/// Supports formats: `http://host:port`, `socks5://host:port`, or `host:port`.
/// Leave empty to use system default networking (no custom proxy).
static var httpProxyURL = Key<String>("httpProxyURL", default: "")

static var enableAppleOfflineTranslation = Key<Bool>(
"enableAppleOfflineTranslation", default: false
)
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Ali/AliService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class AliService: QueryService {
result = currentResult
}

let request = AF.request("https://mt.aliyuncs.com", method: .post, parameters: param)
let request = EAF.request("https://mt.aliyuncs.com", method: .post, parameters: param)

queryModel.setStop({
request.cancel()
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Baidu/BaiduApiTranslate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BaiduApiTranslate: NSObject {
"sign": signMd5,
]

let request = AF.request(
let request = EAF.request(
"https://fanyi-api.baidu.com/api/trans/vip/translate",
method: .post,
parameters: param,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Baidu/BaiduService+OCR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension BaiduService {
let url = "\(kBaiduTranslateURL)/getocr"

do {
let response = try await AF.upload(
let response = try await EAF.upload(
multipartFormData: { formData in
formData.append(imageData, withName: "image", fileName: "blob", mimeType: "image/png")
formData.append(Data((fromLang ?? "").utf8), withName: "from")
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Baidu/BaiduService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ final class BaiduService: QueryService {
let url = "\(kBaiduTranslateURL)/langdetect"

do {
let response = try await AF.request(
let response = try await EAF.request(
url,
method: .post,
parameters: ["query": queryString],
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Bing/BingRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class BingRequest {
)
-> DataRequest {
let encoding: ParameterEncoding = method == .get ? URLEncoding.default : URLEncoding.httpBody
let request = AF.request(
let request = EAF.request(
url,
method: method,
parameters: parameters,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Caiyun/CaiyunService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public final class CaiyunService: QueryService {
result = currentResult
}

let request = AF.request(
let request = EAF.request(
apiEndPoint,
method: .post,
parameters: parameters,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Claude/ClaudeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public final class ClaudeService: StreamService {
)
let urlRequest = try createURLRequest(body: requestBody)

let (asyncBytes, response) = try await URLSession.shared.bytes(for: urlRequest)
let (asyncBytes, response) = try await EURLSession.bytes(for: urlRequest)
try await validateHTTPResponse(response, asyncBytes: asyncBytes)

try await processStreamBytes(asyncBytes, continuation: continuation)
Expand Down
4 changes: 2 additions & 2 deletions Easydict/Swift/Service/DeepL/DeepLService+Translate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension DeepLService {

let startTime = CFAbsoluteTimeGetCurrent()

let dataRequest = AF.request(request)
let dataRequest = EAF.request(request)
.validate(statusCode: 200 ..< 300)

dataRequest.responseData { [weak self] response in
Expand Down Expand Up @@ -196,7 +196,7 @@ extension DeepLService {

let authorization = "DeepL-Auth-Key \(authKey)"
let startTime = CFAbsoluteTimeGetCurrent()
let request = AF.request(
let request = EAF.request(
url,
method: .post,
parameters: params,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Doubao/DoubaoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public final class DoubaoService: StreamService {
let requestBody = buildRequestBody(text: text, transType: transType)
let urlRequest = try createURLRequest(body: requestBody)

let (asyncBytes, response) = try await URLSession.shared.bytes(for: urlRequest)
let (asyncBytes, response) = try await EURLSession.bytes(for: urlRequest)
try validateHTTPResponse(response)

try await processStreamBytes(asyncBytes, continuation: continuation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension GoogleService {
parameters: Parameters? = nil
)
-> DataRequest {
AF.request(
EAF.request(
url,
method: .get,
parameters: parameters,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/NiuTrans/NiuTransService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extension NiuTransService {
"source": "Easydict",
]

let request = AF.request(
let request = EAF.request(
kNiuTransAPIURL,
method: .post,
parameters: params,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Ollama/OllamaService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class OllamaService: BaseOpenAIService {
}

let modelsURL = trueBaseURL.appendingPathComponent("api/tags")
let dataTask = AF.request(modelsURL).serializingDecodable(OllamaModels.self)
let dataTask = EAF.request(modelsURL).serializingDecodable(OllamaModels.self)
return try await dataTask.value
}
}
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Tencent/TencentService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public final class TencentService: QueryService {
result = currentResult
}

let request = AF.request(
let request = EAF.request(
endpoint,
method: .post,
parameters: parameters,
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Volcano/VolcanoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public final class VolcanoService: QueryService {

let afHost = host + uri + "?" + queryString

let request = AF.request(
let request = EAF.request(
afHost,
method: .post,
parameters: parameters,
Expand Down
4 changes: 2 additions & 2 deletions Easydict/Swift/Service/Youdao/YoudaoService+Dict.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension YoudaoService {

do {
// Get the raw data
let responseData = try await AF.request(
let responseData = try await EAF.request(
url,
method: .post,
parameters: parameters
Expand Down Expand Up @@ -128,7 +128,7 @@ extension YoudaoService {

do {
// Get the raw data
let responseData = try await AF.request(
let responseData = try await EAF.request(
url,
method: .get,
parameters: parameters
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Youdao/YoudaoService+OCR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension YoudaoService {
let parameters = ["imgBase": imageBase]

do {
let response = try await AF.request(
let response = try await EAF.request(
"https://aidemo.youdao.com/ocrtransapi1",
method: .post,
parameters: parameters,
Expand Down
4 changes: 2 additions & 2 deletions Easydict/Swift/Service/Youdao/YoudaoService+Translate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension YoudaoService {
], uniquingKeysWith: { _, new in new }
)

let data = try await AF.request(
let data = try await EAF.request(
"\(kYoudaoDictURL)/webtranslate",
method: .post,
parameters: parameters,
Expand Down Expand Up @@ -121,7 +121,7 @@ extension YoudaoService {
], uniquingKeysWith: { _, new in new }
)

return try await AF.request(
return try await EAF.request(
"\(kYoudaoDictURL)/webtranslate/key",
method: .get,
parameters: parameters,
Expand Down
Loading
Loading