Skip to content

Commit

Permalink
Merge branch 'release/4.9.0' into versions
Browse files Browse the repository at this point in the history
  • Loading branch information
FlineDevPublic committed Jan 21, 2022
2 parents e2cd0f3 + e928383 commit 0aa807a
Show file tree
Hide file tree
Showing 31 changed files with 290 additions and 85 deletions.
6 changes: 0 additions & 6 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,6 @@ custom_rules:
name: "Quick Temporary Focus"
message: "Temporary focused Quick examples or groups shouldn't be commited."
severity: warning
remove_where_for_negative_filtering:
included: ".*.swift"
regex: '\.filter *\{ *!\$0\.[^\}&|]+\}'
name: "Remove Where for Negative Filtering"
message: "Use `remove(where:)` instead of `filter(where not ...)` for performance."
severity: warning
single_line_enum_cases:
included: ".*.swift"
regex: 'enum [^\{]+\{\s*(?:\s*\/\/[^\n]*)*\s*case\s+[^,(\n]+,'
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.8.0"
s.version = "4.9.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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se
### Security
- None.

## [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.
PR: [#242](https://github.com/Flinesoft/BartyCrouch/pull/242) | Author: [Cihat Gündüz](https://github.com/Jeehut)
- Added a new option `subpathsToIgnore` to provide subpaths to be ignored (with case-insensitive comparison) inside of the provided `paths`. New option defaults to `[".git", "carthage", "pods", "build", ".build", "docs"]` if not specified otherwise.
PR: [#242](https://github.com/Flinesoft/BartyCrouch/pull/242) | Author: [Cihat Gündüz](https://github.com/Jeehut)
### Fixed
- Removed ignoring all `InfoPlist.strings` files by default. If you want this to actually be the case, just add `InfoPlist.strings` to the array in the new `subpathsToIgnore` option, e.g.: `subPathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs", "InfoPlist.strings"]`
PR: [#242](https://github.com/Flinesoft/BartyCrouch/pull/242) | Author: [Cihat Gündüz](https://github.com/Jeehut)
- Less situations where the empty `tmpstring` folder continues to exist.
PR: [#238](https://github.com/Flinesoft/BartyCrouch/pull/238) | Author: [Benjamin Erhart](https://github.com/tladesignz)
- Only apply ignores on subpaths of explicitly mentioned folders in `path` options, don't ignore any paths that are explicitly mentioned.
PR: [#240](https://github.com/Flinesoft/BartyCrouch/pull/240) | Author: [Benjamin Erhart](https://github.com/tladesignz)

## [4.8.0] - 2021-10-10
### Changed
- Update SwiftSyntax dependency to Swift 5.5 to support Xcode 13.
Expand Down
4 changes: 2 additions & 2 deletions Formula/bartycrouch.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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.7.1", :revision => "c83fe72d329ffbe2afda6b980c62060699ef6bb7"
url "https://github.com/Flinesoft/BartyCrouch.git", :tag => "4.8.0", :revision => "e2cd0f35fb13b596196091a9ae8de67857e3479a"
head "https://github.com/Flinesoft/BartyCrouch.git"

depends_on :xcode => ["12.0", :build]
depends_on :xcode => ["13.0", :build]

def install
system "make", "install", "prefix=#{prefix}"
Expand Down
9 changes: 8 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ let package = Package(
.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"),

// 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"),
],
targets: [
.executableTarget(
Expand All @@ -37,7 +40,11 @@ let package = Package(
),
.testTarget(
name: "BartyCrouchKitTests",
dependencies: ["BartyCrouchKit", "Toml"]
dependencies: [
"BartyCrouchKit",
.product(name: "CustomDump", package: "swift-custom-dump"),
"Toml"
]
),
.target(
name: "BartyCrouchTranslator",
Expand Down
26 changes: 23 additions & 3 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.8.0-blue.svg"
alt="Version: 4.8.0">
<img src="https://img.shields.io/badge/Version-4.9.0-blue.svg"
alt="Version: 4.9.0">
</a>
<img src="https://img.shields.io/badge/Swift-5.5-FFAC45.svg"
alt="Swift: 5.5">
Expand Down Expand Up @@ -58,7 +58,7 @@ Checkout [this blog post](https://medium.com/@Jeehut/localization-in-swift-like-

## Requirements

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

## Getting Started
Expand Down Expand Up @@ -107,19 +107,24 @@ tasks = ["interfaces", "code", "transform", "normalize"]

[update.interfaces]
paths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
defaultToBase = false
ignoreEmptyStrings = false
unstripped = false
ignoreKeys = ["#bartycrouch-ignore!", "#bc-ignore!", "#i!"]

[update.code]
codePaths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
localizablePaths = ["."]
defaultToKeys = false
additive = true
unstripped = false
ignoreKeys = ["#bartycrouch-ignore!", "#bc-ignore!", "#i!"]

[update.transform]
codePaths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
localizablePaths = ["."]
transformer = "foundation"
supportedLanguageEnumPath = "."
Expand All @@ -128,12 +133,14 @@ translateMethodName = "translate"

[update.normalize]
paths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
sourceLocale = "en"
harmonizeWithSource = true
sortByKeys = true

[lint]
paths = ["."]
subpathsToIgnore = [".git", "carthage", "pods", "build", ".build", "docs"]
duplicateKeys = true
emptyValues = true
```
Expand Down Expand Up @@ -235,28 +242,33 @@ tasks = ["interfaces", "code", "transform", "normalize"]
<details><summary>Options for <code>interfaces</code></summary>

- `paths`: The directory / directories to search for Storyboards & XIB files.
- `subpathsToIgnore`: The subpaths to be ignored inside the directories found via the `paths` option.
- `defaultToBase`: Add Base translation as value to new keys.
- `ignoreEmptyStrings`: Doesn't add views with empty values.
- `unstripped`: Keeps whitespaces at beginning & end of Strings files.
- `ignoreKeys`: Keys (e.g. in the comment) indicating that specific translation entries should be ignored when generating String files. Useful to ignore strings that are gonna be translated in code.

</details>

<details><summary>Options for <code>code</code></summary>

- `codePaths`: The directory / directories to search for Swift code files.
- `subpathsToIgnore`: The subpaths to be ignored inside the directories found via the `paths` option.
- `localizablePaths`: The enclosing path(s) containing the localized `Localizable.strings` files.
- `defaultToKeys`: Add new keys both as key and value.
- `additive`: Prevents cleaning up keys not found in code.
- `customFunction`: Use alternative name to `NSLocalizedString`.
- `customLocalizableName`: Use alternative name for `Localizable.strings`.
- `unstripped`: Keeps whitespaces at beginning & end of Strings files.
- `plistArguments`: Use a plist file to store all the code files for the ExtractLocStrings tool. (Recommended for large projects.)
- `ignoreKeys`: Keys (e.g. in the comment) indicating that specific translation entries should be ignored when generating String files.

</details>

<details><summary>Options for <code>transform</code></summary>

- `codePaths`: The directory / directories to search for Swift code files.
- `subpathsToIgnore`: The subpaths to be ignored inside the directories found via the `paths` option.
- `localizablePaths`: The enclosing path(s) containing the localized `Localizable.strings` files.
- `transformer`: Specifies the replacement code. Use `foundation` for `NSLocalizedString` or `swiftgenStructured` for `L10n` entries.
- `supportedLanguageEnumPath`: The enclosing path containing the `SupportedLanguage` enum.
Expand All @@ -269,6 +281,7 @@ tasks = ["interfaces", "code", "transform", "normalize"]
<details><summary>Options for <code>translate</code></summary>

- `paths`: The directory / directories to search for Strings files.
- `subpathsToIgnore`: The subpaths to be ignored inside the directories found via the `paths` option.
- `translator`: Specifies the translation API. Use `microsoftTranslator` or `deepL`.
- `secret`: Your [Microsoft Translator Text API Subscription Key](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup#authentication-key) or [Authentication Key for DeepL API](https://www.deepl.com/pro-account/plan).
- `sourceLocale`: The source language to translate from.
Expand All @@ -278,6 +291,7 @@ tasks = ["interfaces", "code", "transform", "normalize"]
<details><summary>Options for <code>normalize</code></summary>

- `paths`: The directory / directories to search for Strings files.
- `subpathsToIgnore`: The subpaths to be ignored inside the directories found via the `paths` option.
- `sourceLocale`: The source language to harmonize keys of other languages with.
- `harmonizeWithSource`: Synchronizes keys with source language.
- `sortByKeys`: Alphabetically sorts translations by their keys.
Expand Down Expand Up @@ -390,6 +404,12 @@ func updateTimeLabel(minutes: Int) {

The `%d minute(s) ago` key will be taken from Localizable.stringsdict file, not from Localizable.strings, that's why it should be ignored by BartyCrouch.

### Things to Know:

- Files named or files in folders named ".git", "carthage", "pods", "build",
".build" and "docs" (case insensitive) will always be ignored.


## Donation

BartyCrouch was brought to you by [Cihat Gündüz](https://github.com/Jeehut) in his free time. If you want to thank me and support the development of this project, please **make a small donation on [PayPal](https://paypal.me/Dschee/5EUR)**. In case you also like my other [open source contributions](https://github.com/Flinesoft) and [articles](https://medium.com/@Jeehut), please consider motivating me by **becoming a sponsor on [GitHub](https://github.com/sponsors/Jeehut)** or a **patron on [Patreon](https://www.patreon.com/Jeehut)**.
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.8.0",
version: "4.9.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 @@ -4,6 +4,7 @@ import Toml

struct LintOptions {
let paths: [String]
let subpathsToIgnore: [String]
let duplicateKeys: Bool
let emptyValues: Bool
}
Expand All @@ -14,6 +15,7 @@ extension LintOptions: TomlCodable {

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
)
Expand All @@ -23,6 +25,7 @@ extension LintOptions: TomlCodable {
var lines: [String] = ["[lint]"]

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import Toml

struct CodeOptions {
let codePaths: [String]
let subpathsToIgnore: [String]
let localizablePaths: [String]
let defaultToKeys: Bool
let additive: Bool
let customFunction: String?
let customLocalizableName: String?
let unstripped: Bool
let plistArguments: Bool
let ignoreKeys: [String]
}

extension CodeOptions: TomlCodable {
Expand All @@ -19,20 +21,23 @@ extension CodeOptions: TomlCodable {

return CodeOptions(
codePaths: toml.filePaths(update, code, singularKey: "codePath", pluralKey: "codePaths"),
subpathsToIgnore: toml.array(update, code, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore,
localizablePaths: toml.filePaths(update, code, singularKey: "localizablePath", pluralKey: "localizablePaths"),
defaultToKeys: toml.bool(update, code, "defaultToKeys") ?? false,
additive: toml.bool(update, code, "additive") ?? true,
customFunction: toml.string(update, code, "customFunction"),
customLocalizableName: toml.string(update, code, "customLocalizableName"),
unstripped: toml.bool(update, code, "unstripped") ?? false,
plistArguments: toml.bool(update, code, "plistArguments") ?? true
plistArguments: toml.bool(update, code, "plistArguments") ?? true,
ignoreKeys: toml.array(update, code, "ignoreKeys") ?? Constants.defaultIgnoreKeys
)
}

func tomlContents() -> String {
var lines: [String] = ["[update.code]"]

lines.append("codePaths = \(codePaths)")
lines.append("subpathsToIgnore = \(subpathsToIgnore)")
lines.append("localizablePaths = \(localizablePaths)")
lines.append("defaultToKeys = \(defaultToKeys)")
lines.append("additive = \(additive)")
Expand All @@ -47,6 +52,7 @@ extension CodeOptions: TomlCodable {

lines.append("unstripped = \(unstripped)")
lines.append("plistArguments = \(plistArguments)")
lines.append("ignoreKeys = \(Constants.defaultIgnoreKeys)")

return lines.joined(separator: "\n")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import Toml

struct InterfacesOptions {
let paths: [String]
let subpathsToIgnore: [String]
let defaultToBase: Bool
let ignoreEmptyStrings: Bool
let unstripped: Bool
let ignoreKeys: [String]
}

extension InterfacesOptions: TomlCodable {
Expand All @@ -15,19 +17,23 @@ extension InterfacesOptions: TomlCodable {

return InterfacesOptions(
paths: toml.filePaths(update, interfaces, singularKey: "path", pluralKey: "paths"),
subpathsToIgnore: toml.array(update, interfaces, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore,
defaultToBase: toml.bool(update, interfaces, "defaultToBase") ?? false,
ignoreEmptyStrings: toml.bool(update, interfaces, "ignoreEmptyStrings") ?? false,
unstripped: toml.bool(update, interfaces, "unstripped") ?? false
unstripped: toml.bool(update, interfaces, "unstripped") ?? false,
ignoreKeys: toml.array(update, interfaces, "ignoreKeys") ?? Constants.defaultIgnoreKeys
)
}

func tomlContents() -> String {
var lines: [String] = ["[update.interfaces]"]

lines.append("paths = \(paths)")
lines.append("subpathsToIgnore = \(subpathsToIgnore)")
lines.append("defaultToBase = \(defaultToBase)")
lines.append("ignoreEmptyStrings = \(ignoreEmptyStrings)")
lines.append("unstripped = \(unstripped)")
lines.append("ignoreKeys = \(ignoreKeys)")

return lines.joined(separator: "\n")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Toml

struct NormalizeOptions {
let paths: [String]
let subpathsToIgnore: [String]
let sourceLocale: String
let harmonizeWithSource: Bool
let sortByKeys: Bool
Expand All @@ -15,6 +16,7 @@ extension NormalizeOptions: TomlCodable {

return NormalizeOptions(
paths: toml.filePaths(update, normalize, singularKey: "path", pluralKey: "paths"),
subpathsToIgnore: toml.array(update, normalize, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore,
sourceLocale: toml.string(update, normalize, "sourceLocale") ?? "en",
harmonizeWithSource: toml.bool(update, normalize, "harmonizeWithSource") ?? true,
sortByKeys: toml.bool(update, normalize, "sortByKeys") ?? true
Expand All @@ -25,6 +27,7 @@ extension NormalizeOptions: TomlCodable {
var lines: [String] = ["[update.normalize]"]

lines.append("paths = \(paths)")
lines.append("subpathsToIgnore = \(subpathsToIgnore)")
lines.append("sourceLocale = \"\(sourceLocale)\"")
lines.append("harmonizeWithSource = \(harmonizeWithSource)")
lines.append("sortByKeys = \(sortByKeys)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Toml

struct TransformOptions {
let codePaths: [String]
let subpathsToIgnore: [String]
let localizablePaths: [String]
let transformer: Transformer
let supportedLanguageEnumPath: String
Expand All @@ -26,6 +27,7 @@ extension TransformOptions: TomlCodable {

return TransformOptions(
codePaths: toml.filePaths(update, transform, singularKey: "codePath", pluralKey: "codePaths"),
subpathsToIgnore: toml.array(update, transform, "subpathsToIgnore") ?? Constants.defaultSubpathsToIgnore,
localizablePaths: toml.filePaths(update, transform, singularKey: "localizablePath", pluralKey: "localizablePaths"),
transformer: transformer,
supportedLanguageEnumPath: toml.string(update, transform, "supportedLanguageEnumPath") ?? ".",
Expand All @@ -39,6 +41,7 @@ extension TransformOptions: TomlCodable {
var lines: [String] = ["[update.transform]"]

lines.append("codePaths = \(codePaths)")
lines.append("subpathsToIgnore = \(subpathsToIgnore)")
lines.append("localizablePaths = \(localizablePaths)")
lines.append("transformer = \"\(transformer.rawValue)\"")
lines.append("supportedLanguageEnumPath = \"\(supportedLanguageEnumPath)\"")
Expand Down
Loading

0 comments on commit 0aa807a

Please sign in to comment.