Skip to content

Commit

Permalink
Merge branch 'release/4.15.0' into versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed May 22, 2023
2 parents a81a6ab + 7cc61c1 commit a2fc2f6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BartyCrouch.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

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

s.description = <<-DESC
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
### Security
- None.

## [4.15.0] - 2023-05-22
### Changed
- Improved implementation of DeepL API client for more reliable escaping than the previous manual escaping logic.
PR: [#277](https://github.com/FlineDev/BartyCrouch/issues/277) | Author: [Nico](https://github.com/NickAtGit)
- Upgraded Swift-Syntax dependency to work with Swift 5.8 to fix build issues.
PR: [#279](https://github.com/FlineDev/BartyCrouch/issues/279) | Author: [Alex Deem](https://github.com/alexdeem)

## [4.14.0] - 2022-12-14
### Added
- Support for Swift 5.7 and Xcode 14, dropping support for older versions and fixing the 'could not parse syntax tree' issue.
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
.package(name: "Rainbow", url: "https://github.com/onevcat/Rainbow.git", from: "3.1.5"),
.package(name: "SwiftCLI", url: "https://github.com/jakeheis/SwiftCLI.git", from: "6.0.3"),
.package(name: "Toml", url: "https://github.com/jdfergason/swift-toml.git", .branch("master")),
.package(url: "https://github.com/apple/swift-syntax.git", .branch("0.50700.1")),
.package(url: "https://github.com/apple/swift-syntax.git", from: "508.0.0"),

// A collection of tools for debugging, diffing, and testing your application's data structures.
.package(url: "https://github.com/pointfreeco/swift-custom-dump.git", from: "0.3.0"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/BartyCrouch/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SwiftCLI
// MARK: - CLI
let cli = CLI(
name: "bartycrouch",
version: "4.14.2",
version: "4.15.0",
description: "Incrementally update & translate your Strings files from code or interface files."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SupportedLanguagesReader: SyntaxVisitor {
typeName: String
) {
self.typeName = typeName
super.init(viewMode: .sourceAccurate)
}

override func visit(_ enumDeclaration: EnumDeclSyntax) -> SyntaxVisitorContinueKind {
Expand Down
25 changes: 18 additions & 7 deletions Sources/BartyCrouchTranslator/DeeplApi/DeepLApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,24 @@ extension DeepLApi: Endpoint {
var method: HttpMethod {
switch self {
case .translate(let texts, let sourceLanguage, let targetLanguage, let authKey):
let textEntries = texts.map { "text=\($0.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!)" }
.joined(separator: "&")
let authKeyEntry = "auth_key=\(authKey)"
let sourceLanguageEntry = "source_lang=\(sourceLanguage.deepLParameterValue)"
let targetLanguageEntry = "target_lang=\(targetLanguage.deepLParameterValue)"
let bodyString = [authKeyEntry, sourceLanguageEntry, targetLanguageEntry, textEntries].joined(separator: "&")
return .post(body: bodyString.data(using: .utf8)!)

let authKeyItem = URLQueryItem(name: "auth_key", value: authKey)
let textItems = texts.map { URLQueryItem(name: "text", value: $0) }
let targetLangItem = URLQueryItem(name: "target_lang", value: targetLanguage.deepLParameterValue)
let sourceLangItem = URLQueryItem(name: "source_lang", value: sourceLanguage.deepLParameterValue)

var components = URLComponents()
components.queryItems = ([authKeyItem, targetLangItem, sourceLangItem] + textItems).compactMap { $0 }

guard var queryItemsString = components.string else {
fatalError("Invalid arguments.")
}
// queryItemsString starts with a ? but post API expects the query string without leading ?
if queryItemsString.hasPrefix("?") {
queryItemsString.removeFirst()
}

return .post(body: queryItemsString.data(using: .utf8)!)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SupportingFiles/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.14.2</string>
<string>4.15.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DeepLTranslatorApiTests: XCTestCase {
switch apiProvider.performRequestAndWait(on: endpoint, decodeBodyTo: DeepLTranslateResponse.self) {
case let .success(translateResponses):
XCTAssertEqual(translateResponses.translations[0].text, "Wie alt sind Sie?")
XCTAssertEqual(translateResponses.translations[1].text, "Liebe")

case let .failure(failure):
XCTFail(failure.localizedDescription)
Expand Down

0 comments on commit a2fc2f6

Please sign in to comment.