Skip to content

Commit

Permalink
Merge branch 'release/4.2.0' into versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Apr 24, 2020
2 parents 201b0b0 + d1a5f82 commit 49b4cf2
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 24 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.1.1"
s.version = "4.2.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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
### Security
- None.

## [4.2.0] - 2020-04-24
### Added
- Added new `-p` / `--path` option to run BartyCrouch from a different path than current.
Issues: [#166](https://github.com/Flinesoft/BartyCrouch/issues/166), [#177](https://github.com/Flinesoft/BartyCrouch/issues/177) | PR: [#181](https://github.com/Flinesoft/BartyCrouch/pull/181) | Author: [Cihat Gündüz](https://github.com/Jeehut)
### Removed
- Removed code magic that used the localization comment from Interface Builder files as a source for new translation values.
Issue: [#140](https://github.com/Flinesoft/BartyCrouch/issues/140) | PR: [#182](https://github.com/Flinesoft/BartyCrouch/pull/182) | Author: [Cihat Gündüz](https://github.com/Jeehut)
### Fixed
- Normalize sortByKeys no longer adds empty line to begining of .strings file.
Issue: [#178](https://github.com/Flinesoft/BartyCrouch/issues/178) | PR: [#180](https://github.com/Flinesoft/BartyCrouch/pull/180) | Author: [Patrick Wolowicz](https://github.com/hactar)

## [4.1.1] - 2020-04-16
### Fixed
- Fixed crashes in projects with large number of files by introducing new `plist` file based approach for passing arguments. See the new `--plist-arguments` option. Will be automatically turned on when needed (many files in project).
Expand Down
2 changes: 1 addition & 1 deletion Formula/bartycrouch.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Bartycrouch < Formula
desc "Incrementally update/translate your Strings files"
homepage "https://github.com/Flinesoft/BartyCrouch"
url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.1.0", :revision => "be2404129aa6141b00a2e7fd61e7dd8ab088d1d6"
url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.1.1", :revision => "201b0b02c196dcda14c806a539ab963284abeeaf"
head "https://github.com/Flinesoft/BartyCrouch.git"

depends_on :xcode => ["11.4", :build]
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
},
{
"package": "Toml",
"repositoryURL": "https://github.com/Jeehut/swift-toml.git",
"repositoryURL": "https://github.com/jdfergason/swift-toml.git",
"state": {
"branch": "master",
"revision": "e0f7f568de4a9ae760a3b2d495616e180fafa5ac",
"revision": "921c047a89bcc26fac4e8ead5a280bf0f69939f9",
"version": null
}
},
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.package(name: "MungoHealer", url: "https://github.com/JamitLabs/MungoHealer.git", from: "0.3.2"),
.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.1"),
.package(name: "Toml", url: "https://github.com/Jeehut/swift-toml.git", .branch("master")),
.package(name: "Toml", url: "https://github.com/jdfergason/swift-toml.git", .branch("master")),
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", .exact("0.50200.0")),
],
targets: [
Expand All @@ -39,7 +39,7 @@ let package = Package(
),
.testTarget(
name: "BartyCrouchKitTests",
dependencies: ["BartyCrouchKit", "Toml", "SwiftSyntax"],
dependencies: ["BartyCrouchKit", "Toml"],
path: "Tests/BartyCrouchKitTests"
),
.target(
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<img src="https://api.codacy.com/project/badge/Coverage/7b34ad9193c2438aa32aa29a0490451f"/>
</a>
<a href="https://github.com/Flinesoft/BartyCrouch/releases">
<img src="https://img.shields.io/badge/Version-4.1.1-blue.svg"
alt="Version: 4.1.1">
<img src="https://img.shields.io/badge/Version-4.2.0-blue.svg"
alt="Version: 4.2.0">
</a>
<img src="https://img.shields.io/badge/Swift-5.2-FFAC45.svg"
alt="Swift: 5.2">
Expand Down Expand Up @@ -215,6 +215,7 @@ Also the following command line options can be provided:
- **`-v`, `--verbose`**: Prints more detailed information about the executed command.
- **`-x`, `--xcode-output`**: Prints warnings & errors in Xcode compatible format.
- **`-w`, `--fail-on-warnings`**: Returns a failed status code if any warning is encountered.
- **`-p`, `--path`: Specifies a different path than current to run BartyCrouch from there.

### `update` subcommand

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.1.1",
version: "4.2.0",
description: "Incrementally update & translate your Strings files from code or interface files."
)

Expand Down
1 change: 1 addition & 0 deletions Sources/BartyCrouchKit/Commands/InitCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class InitCommand: Command {

// MARK: - Instance Methods
public func execute() throws {
GlobalOptions.setup()
InitTaskHandler().perform()
CommandExecution.current.failIfNeeded()
}
Expand Down
1 change: 1 addition & 0 deletions Sources/BartyCrouchKit/Commands/LintCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class LintCommand: Command {

// MARK: - Instance Methods
public func execute() throws {
GlobalOptions.setup()
let lintOptions = try Configuration.load().lintOptions
LintTaskHandler(options: lintOptions).perform()
CommandExecution.current.failIfNeeded()
Expand Down
1 change: 1 addition & 0 deletions Sources/BartyCrouchKit/Commands/UpdateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class UpdateCommand: Command {

// MARK: - Instance Methods
public func execute() throws {
GlobalOptions.setup()
let updateOptions = try Configuration.load().updateOptions

for task in updateOptions.tasks {
Expand Down
13 changes: 1 addition & 12 deletions Sources/BartyCrouchKit/FileHandling/StringsFileUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@ public class StringsFileUpdater {

let oldTranslation = oldTranslations.first { oldKey, _, _, _ in oldKey == newTranslation.key }

// get value from default comment structure if possible
let oldBaseValue: String? = {
guard let oldComment = oldTranslation?.comment, let foundMatch = defaultCommentStructureMatches(inString: oldComment) else {
return nil
}

return (oldComment as NSString).substring(with: foundMatch.range(at: 1))
}()

let updatedComment: String? = {
// add new comment if none existed before
guard let oldComment = oldTranslation?.comment else { return newTranslation.comment }
Expand Down Expand Up @@ -118,8 +109,6 @@ public class StringsFileUpdater {

if override { return newTranslationValue } // override with new value in force update mode

if let oldBaseValue = oldBaseValue, oldBaseValue == oldValue { return newTranslationValue } // update base value

// keep existing translation
return oldValue
}()
Expand Down Expand Up @@ -364,7 +353,7 @@ public class StringsFileUpdater {
}

func stringFromTranslations(translations: [TranslationEntry]) -> String {
return "\n" + translations.map { key, value, comment, _ -> String in
return translations.map { key, value, comment, _ -> String in
let translationLine = "\"\(key)\" = \"\(value)\";"
if let comment = comment { return "/*\(comment)*/\n" + translationLine }
return translationLine
Expand Down
9 changes: 8 additions & 1 deletion Sources/BartyCrouchKit/Globals/GlobalOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ public enum GlobalOptions {
static let verbose = Flag("-v", "--verbose", description: "Prints more detailed information about the executed command")
static let xcodeOutput = Flag("-x", "--xcode-output", description: "Prints warnings & errors in Xcode compatible format")
static let failOnWarnings = Flag("-w", "--fail-on-warnings", description: "Returns a failed status code if any warning is encountered")
static let path = Key<String>("-p", "--path", description: "Specifies a different path than current to run BartyCrouch from there")

public static var all: [Option] {
return [verbose, xcodeOutput, failOnWarnings]
return [verbose, xcodeOutput, failOnWarnings, path]
}

static func setup() {
if let path = path.value {
FileManager.default.changeCurrentDirectoryPath(path)
}
}
}
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.1.1</string>
<string>4.2.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
@@ -1,5 +1,4 @@
@testable import BartyCrouchKit
import SwiftSyntax
import XCTest

class CodeFileHandlerTests: XCTestCase {
Expand Down

0 comments on commit 49b4cf2

Please sign in to comment.