Skip to content

Commit

Permalink
Merge branch 'release/4.10.0' into versions
Browse files Browse the repository at this point in the history
  • Loading branch information
FlineDevPublic committed Mar 18, 2022
2 parents 0aa807a + eeaf071 commit a832f73
Show file tree
Hide file tree
Showing 101 changed files with 3,421 additions and 2,987 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@ jobs:
with:
xcode-version: latest-stable

- name: Setup secrets.json
run: |
echo '
{
"deepLApiKey": "${{ secrets.DEEP_L_API_KEY }}",
"microsoftSubscriptionKey": "${{ secrets.MICROSOFT_SUBSCRIPTION_KEY }}"
}
' >> Tests/BartyCrouchTranslatorTests/Secrets/secrets.json
- name: Run tests
run: swift test -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ Package.resolved
*.xcodeproj
.swiftpm
.build/

# Project-specific
secrets.json
15 changes: 15 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"lineBreakAroundMultilineExpressionChainComponents": true,
"lineBreakBeforeControlFlowKeywords": true,
"lineBreakBeforeEachArgument": true,
"lineBreakBeforeEachGenericRequirement": true,
"lineLength": 120,
"prioritizeKeepingFunctionOutputTogether": true,
"rules": {
"NeverUseImplicitlyUnwrappedOptionals": true,
"NoLeadingUnderscores": true,
"ValidateDocumentationComments": true,
},
"tabWidth": 2,
"version": 1,
}
26 changes: 6 additions & 20 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ opt_in_rules:
- yoda_condition

disabled_rules:
- file_length
- force_cast
- function_body_length
- line_length
- opening_brace
- statement_position
- todo
- trailing_comma
- type_name

included:
Expand Down Expand Up @@ -94,8 +100,6 @@ identifier_name:
- db
- to

line_length: 160

type_contents_order:
order:
- case
Expand Down Expand Up @@ -132,12 +136,6 @@ custom_rules:
name: "Class Name Suffix View Controller"
message: "All `ViewController` subclasses should end on `ViewController`."
severity: warning
closing_brace_whitespace:
included: ".*.swift"
regex: '(?:\n| {2,})\}\)? *\n *[^ \n\})\]s#"]'
name: "Closing Brace Whitespace"
message: "Empty line required after closing curly braces if code with same indentation follows."
severity: warning
closure_params_parantheses:
included: ".*.swift"
regex: '\{\s*\([^):]+\)\s*in'
Expand Down Expand Up @@ -324,12 +322,6 @@ custom_rules:
name: "Too Much Unindentation"
message: "Don't unindent code by more than 4 whitespaces."
severity: warning
tuple_index:
included: ".*.swift"
regex: '(\$\d|\w*[^\d \(\[\{])\.\d'
name: "Tuple Index"
message: "Prevent unwraping tuples by their index – define a typealias with named components instead."
severity: warning
unnecessary_case_break:
included: ".*.swift"
regex: '(case |default)(?:[^\n\}]+\n){2,}\s*break *\n|\n *\n *break(?:\n *\n|\n *\})'
Expand All @@ -354,12 +346,6 @@ custom_rules:
name: "View Controller Variable Naming"
message: "Always name your view controller variables with the suffix `ViewCtrl`."
severity: warning
whitespace_around_range_operators:
included: ".*.swift"
regex: '\w\.\.[<\.]\w'
name: "Whitespace around Range Operators"
message: "A range operator should be surrounded by a single whitespace."
severity: warning
whitespace_comment_start:
included: ".*.swift"
regex: '[^:#\]\}\)][^:#\]\}\)]\/\/[^\s\/]'
Expand Down
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.9.0"
s.version = "4.10.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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
### Security
- None.

## [4.10.0] - 2022-03-18
### Changed
- Update SwiftSyntax dependency to Swift 5.5 to support Xcode 13.
Issues: [#201](https://github.com/Flinesoft/BartyCrouch/issues/201), [#249](https://github.com/Flinesoft/BartyCrouch/issues/249) | Author: [Cihat Gündüz](https://github.com/Jeehut)

## [4.9.0] - 2022-01-21
### Added
- Added a new option `ignoreKeys` to provide custom alternatives to the default `bc-ignore` kind of keys if needed. New option defaults to `["#bartycrouch-ignore!", "#bc-ignore!", "#i!"]` if not specified otherwise.
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.8.0", :revision => "e2cd0f35fb13b596196091a9ae8de67857e3479a"
url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.9.0", :revision => "0aa807a2e853a146ea55808edeb1431e1994b070"
head "https://github.com/Flinesoft/BartyCrouch.git"

depends_on :xcode => ["13.0", :build]
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@ all: bartycrouch
bartycrouch: $(SOURCES)
@swift build \
-c release \
--arch arm64 --arch x86_64 \
--disable-sandbox \
--build-path "$(BUILDDIR)"

.PHONY: install
install: bartycrouch
@install -d "$(bindir)" "$(libdir)"
@install "$(BUILDDIR)/release/bartycrouch" "$(bindir)"
@install "$(BUILDDIR)/Apple/Products/Release/bartycrouch" "$(bindir)"

.PHONY: portable_zip
portable_zip: bartycrouch
rm -f "$(BUILDDIR)/release/portable_bartycrouch.zip"
zip -j "$(BUILDDIR)/release/portable_bartycrouch.zip" "$(BUILDDIR)/release/bartycrouch" "$(REPODIR)/LICENSE"
echo "Portable ZIP created at: $(BUILDDIR)/release/portable_bartycrouch.zip"
rm -f "$(BUILDDIR)/Apple/Products/Release/portable_bartycrouch.zip"
zip -j "$(BUILDDIR)/Apple/Products/Release/portable_bartycrouch.zip" "$(BUILDDIR)/Apple/Products/Release/bartycrouch" "$(REPODIR)/LICENSE"
echo "Portable ZIP created at: $(BUILDDIR)/Apple/Products/Release/portable_bartycrouch.zip"

.PHONY: uninstall
uninstall:
Expand Down
34 changes: 27 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let package = Package(
platforms: [.macOS(.v10_15)],
products: [
.executable(name: "bartycrouch", targets: ["BartyCrouch"]),
.library(name: "BartyCrouchConfiguration", targets: ["BartyCrouchConfiguration"]),
.library(name: "BartyCrouchKit", targets: ["BartyCrouchKit"]),
.library(name: "BartyCrouchTranslator", targets: ["BartyCrouchTranslator"]),
],
Expand All @@ -16,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(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git", from: "0.50500.0"),
.package(url: "https://github.com/apple/swift-syntax.git", .exact("0.50600.1")),

// 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 All @@ -29,21 +30,35 @@ let package = Package(
.target(
name: "BartyCrouchKit",
dependencies: [
"BartyCrouchConfiguration",
"BartyCrouchTranslator",
"HandySwift",
"MungoHealer",
"Rainbow",
"SwiftCLI",
"SwiftSyntax",
"Toml",
.product(name: "SwiftSyntaxParser", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
"BartyCrouchUtility",
]
),
.testTarget(
name: "BartyCrouchKitTests",
dependencies: ["BartyCrouchKit"]
),
.target(
name: "BartyCrouchConfiguration",
dependencies: [
"BartyCrouchKit",
"MungoHealer",
"Toml",
"BartyCrouchUtility",
]
),
.testTarget(
name: "BartyCrouchConfigurationTests",
dependencies: [
"BartyCrouchConfiguration",
.product(name: "CustomDump", package: "swift-custom-dump"),
"Toml"
"Toml",
]
),
.target(
Expand All @@ -52,7 +67,12 @@ let package = Package(
),
.testTarget(
name: "BartyCrouchTranslatorTests",
dependencies: ["BartyCrouchTranslator"]
)
dependencies: ["BartyCrouchTranslator"],
exclude: ["Secrets/secrets.json.sample"],
resources: [
.copy("Secrets/secrets.json")
]
),
.target(name: "BartyCrouchUtility"),
]
)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<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.9.0-blue.svg"
alt="Version: 4.9.0">
<img src="https://img.shields.io/badge/Version-4.10.0-blue.svg"
alt="Version: 4.10.0">
</a>
<img src="https://img.shields.io/badge/Swift-5.5-FFAC45.svg"
alt="Swift: 5.5">
<img src="https://img.shields.io/badge/Swift-5.6-FFAC45.svg"
alt="Swift: 5.6">
<a href="https://github.com/Flinesoft/BartyCrouch/blob/main/LICENSE.md">
<img src="https://img.shields.io/badge/License-MIT-lightgrey.svg"
alt="License: MIT">
Expand Down Expand Up @@ -54,11 +54,11 @@

BartyCrouch **incrementally updates** your Strings files from your Code *and* from Interface Builder files. "Incrementally" means that BartyCrouch will by default **keep** both your already **translated values** and even your altered comments. Additionally you can also use BartyCrouch for **machine translating** from one language to 60+ other languages. Using BartyCrouch is as easy as **running a few simple commands** from the command line what can even be **automated using a [build script](#build-script)** within your project.

Checkout [this blog post](https://medium.com/@Jeehut/localization-in-swift-like-a-pro-48164203afe2) to learn how you can effectively use BartyCrouch in your projects.
Checkout [this blog post](https://jeehut.medium.com/localization-in-swift-like-a-pro-48164203afe2?sk=da26d918390db21261b7ead4837286fc) to learn how you can effectively use BartyCrouch in your projects.

## Requirements

- Xcode 13.0+ & Swift 5.5+
- Xcode 13.3+ & Swift 5.6+
- Xcode Command Line Tools (see [here](http://stackoverflow.com/a/9329325/3451975) for installation instructions)

## Getting Started
Expand Down
6 changes: 3 additions & 3 deletions Sources/BartyCrouch/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import SwiftCLI

// MARK: - CLI
let cli = CLI(
name: "bartycrouch",
version: "4.9.0",
description: "Incrementally update & translate your Strings files from code or interface files."
name: "bartycrouch",
version: "4.10.0",
description: "Incrementally update & translate your Strings files from code or interface files."
)

cli.commands = [InitCommand(), UpdateCommand(), LintCommand()]
Expand Down
47 changes: 47 additions & 0 deletions Sources/BartyCrouchConfiguration/Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Foundation
import MungoHealer
import Toml

public struct Configuration {
public static let fileName: String = ".bartycrouch.toml"

public static var configUrl: URL {
return URL(fileURLWithPath: FileManager.default.currentDirectoryPath).appendingPathComponent(Configuration.fileName)
}

public let updateOptions: UpdateOptions
public let lintOptions: LintOptions

public static func load() throws -> Configuration {
let configUrl = self.configUrl

guard FileManager.default.fileExists(atPath: configUrl.path) else {
return try Configuration.make(toml: try Toml(withString: ""))
}

let toml: Toml = try Toml(contentsOfFile: configUrl.path)
return try Configuration.make(toml: toml)
}
}

extension Configuration: TomlCodable {
public static func makeDefault() throws -> Configuration {
return try make(toml: Toml(withString: ""))
}

public static func make(toml: Toml) throws -> Configuration {
let updateOptions = try UpdateOptions.make(toml: toml)
let lintOptions = try LintOptions.make(toml: toml)

return Configuration(updateOptions: updateOptions, lintOptions: lintOptions)
}

public func tomlContents() -> String {
let sections: [String] = [
updateOptions.tomlContents(),
lintOptions.tomlContents(),
]

return sections.joined(separator: "\n\n") + "\n"
}
}
10 changes: 10 additions & 0 deletions Sources/BartyCrouchConfiguration/Extensions/TomlExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Created by Frederick Pietschmann on 15.02.20.

import Foundation
import Toml

public extension Toml {
func filePaths(_ path: String..., singularKey: String, pluralKey: String) -> [String] {
return array(path + [pluralKey]) ?? string(path + [singularKey]).map { [$0] } ?? ["."]
}
}
35 changes: 35 additions & 0 deletions Sources/BartyCrouchConfiguration/Options/LintOptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import BartyCrouchUtility
import Foundation
import MungoHealer
import Toml

public struct LintOptions {
public let paths: [String]
public let subpathsToIgnore: [String]
public let duplicateKeys: Bool
public let emptyValues: Bool
}

extension LintOptions: TomlCodable {
static func make(toml: Toml) throws -> LintOptions {
let lint: String = "lint"

return LintOptions(
paths: toml.filePaths(lint, singularKey: "path", pluralKey: "paths"),
subpathsToIgnore: toml.array(lint, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore,
duplicateKeys: toml.bool(lint, "duplicateKeys") ?? true,
emptyValues: toml.bool(lint, "emptyValues") ?? true
)
}

func tomlContents() -> String {
var lines: [String] = ["[lint]"]

lines.append("paths = \(paths)")
lines.append("subpathsToIgnore = \(subpathsToIgnore)")
lines.append("duplicateKeys = \(duplicateKeys)")
lines.append("emptyValues = \(emptyValues)")

return lines.joined(separator: "\n")
}
}
Loading

0 comments on commit a832f73

Please sign in to comment.