Skip to content

Commit a2fc2f6

Browse files
committed
Merge branch 'release/4.15.0' into versions
2 parents a81a6ab + 7cc61c1 commit a2fc2f6

File tree

8 files changed

+31
-11
lines changed

8 files changed

+31
-11
lines changed

BartyCrouch.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "BartyCrouch"
4-
s.version = "4.14.2"
4+
s.version = "4.15.0"
55
s.summary = "Localization/I18n: Incrementally update/translate your Strings files from .swift, .h, .m(m), .storyboard or .xib files."
66

77
s.description = <<-DESC

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
3131
### Security
3232
- None.
3333

34+
## [4.15.0] - 2023-05-22
35+
### Changed
36+
- Improved implementation of DeepL API client for more reliable escaping than the previous manual escaping logic.
37+
PR: [#277](https://github.com/FlineDev/BartyCrouch/issues/277) | Author: [Nico](https://github.com/NickAtGit)
38+
- Upgraded Swift-Syntax dependency to work with Swift 5.8 to fix build issues.
39+
PR: [#279](https://github.com/FlineDev/BartyCrouch/issues/279) | Author: [Alex Deem](https://github.com/alexdeem)
40+
3441
## [4.14.0] - 2022-12-14
3542
### Added
3643
- Support for Swift 5.7 and Xcode 14, dropping support for older versions and fixing the 'could not parse syntax tree' issue.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let package = Package(
1717
.package(name: "Rainbow", url: "https://github.com/onevcat/Rainbow.git", from: "3.1.5"),
1818
.package(name: "SwiftCLI", url: "https://github.com/jakeheis/SwiftCLI.git", from: "6.0.3"),
1919
.package(name: "Toml", url: "https://github.com/jdfergason/swift-toml.git", .branch("master")),
20-
.package(url: "https://github.com/apple/swift-syntax.git", .branch("0.50700.1")),
20+
.package(url: "https://github.com/apple/swift-syntax.git", from: "508.0.0"),
2121

2222
// A collection of tools for debugging, diffing, and testing your application's data structures.
2323
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "0.3.0"),

Sources/BartyCrouch/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SwiftCLI
55
// MARK: - CLI
66
let cli = CLI(
77
name: "bartycrouch",
8-
version: "4.14.2",
8+
version: "4.15.0",
99
description: "Incrementally update & translate your Strings files from code or interface files."
1010
)
1111

Sources/BartyCrouchKit/FileHandling/SupportedLanguagesReader.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class SupportedLanguagesReader: SyntaxVisitor {
1010
typeName: String
1111
) {
1212
self.typeName = typeName
13+
super.init(viewMode: .sourceAccurate)
1314
}
1415

1516
override func visit(_ enumDeclaration: EnumDeclSyntax) -> SyntaxVisitorContinueKind {

Sources/BartyCrouchTranslator/DeeplApi/DeepLApi.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,24 @@ extension DeepLApi: Endpoint {
5757
var method: HttpMethod {
5858
switch self {
5959
case .translate(let texts, let sourceLanguage, let targetLanguage, let authKey):
60-
let textEntries = texts.map { "text=\($0.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)" }
61-
.joined(separator: "&")
62-
let authKeyEntry = "auth_key=\(authKey)"
63-
let sourceLanguageEntry = "source_lang=\(sourceLanguage.deepLParameterValue)"
64-
let targetLanguageEntry = "target_lang=\(targetLanguage.deepLParameterValue)"
65-
let bodyString = [authKeyEntry, sourceLanguageEntry, targetLanguageEntry, textEntries].joined(separator: "&")
66-
return .post(body: bodyString.data(using: .utf8)!)
60+
61+
let authKeyItem = URLQueryItem(name: "auth_key", value: authKey)
62+
let textItems = texts.map { URLQueryItem(name: "text", value: $0) }
63+
let targetLangItem = URLQueryItem(name: "target_lang", value: targetLanguage.deepLParameterValue)
64+
let sourceLangItem = URLQueryItem(name: "source_lang", value: sourceLanguage.deepLParameterValue)
65+
66+
var components = URLComponents()
67+
components.queryItems = ([authKeyItem, targetLangItem, sourceLangItem] + textItems).compactMap { $0 }
68+
69+
guard var queryItemsString = components.string else {
70+
fatalError("Invalid arguments.")
71+
}
72+
// queryItemsString starts with a ? but post API expects the query string without leading ?
73+
if queryItemsString.hasPrefix("?") {
74+
queryItemsString.removeFirst()
75+
}
76+
77+
return .post(body: queryItemsString.data(using: .utf8)!)
6778
}
6879
}
6980

Sources/SupportingFiles/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>4.14.2</string>
18+
<string>4.15.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>

Tests/BartyCrouchTranslatorTests/DeepLTranslatorApiTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class DeepLTranslatorApiTests: XCTestCase {
2020
switch apiProvider.performRequestAndWait(on: endpoint, decodeBodyTo: DeepLTranslateResponse.self) {
2121
case let .success(translateResponses):
2222
XCTAssertEqual(translateResponses.translations[0].text, "Wie alt sind Sie?")
23+
XCTAssertEqual(translateResponses.translations[1].text, "Liebe")
2324

2425
case let .failure(failure):
2526
XCTFail(failure.localizedDescription)

0 commit comments

Comments
 (0)