Skip to content

Commit

Permalink
Merge branch 'deploy/3.1.0' into productive
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Jun 4, 2016
2 parents b99ae84 + 7d5ed9c commit 7999add
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 12 deletions.
99 changes: 99 additions & 0 deletions BartyCrouch.xcodeproj/xcshareddata/xcschemes/BartyCrouch.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82CDE27E1C6ABF3A00055FE6"
BuildableName = "BartyCrouch.framework"
BlueprintName = "BartyCrouch"
ReferencedContainer = "container:BartyCrouch.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82CDE2871C6ABF3A00055FE6"
BuildableName = "BartyCrouchTests.xctest"
BlueprintName = "BartyCrouchTests"
ReferencedContainer = "container:BartyCrouch.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82CDE27E1C6ABF3A00055FE6"
BuildableName = "BartyCrouch.framework"
BlueprintName = "BartyCrouch"
ReferencedContainer = "container:BartyCrouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82CDE27E1C6ABF3A00055FE6"
BuildableName = "BartyCrouch.framework"
BlueprintName = "BartyCrouch"
ReferencedContainer = "container:BartyCrouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "82CDE27E1C6ABF3A00055FE6"
BuildableName = "BartyCrouch.framework"
BlueprintName = "BartyCrouch"
ReferencedContainer = "container:BartyCrouch.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<p align="center">
<a href="https://github.com/Flinesoft/BartyCrouch/releases">
<img src="https://img.shields.io/badge/Version-3.0.0-blue.svg"
alt="Version: 3.0.0">
<img src="https://img.shields.io/badge/Version-3.1.0-blue.svg"
alt="Version: 3.1.0">
</a>
<a href="#">
<img src="https://img.shields.io/badge/Swift-2.2-DD563C.svg"
Expand All @@ -18,6 +18,16 @@
</a>
</p>

<p align="center">
<a href="#installation">Installation</a>
• <a href="#usage">Usage</a>
• <a href="#build-script">Build Script</a>
• <a href="#migration-guides">Migration Guides</a>
• <a href="https://github.com/Flinesoft/BartyCrouch/issues">Issues</a>
• <a href="#contributing">Contributing</a>
• <a href="#license">License</a>
</p>


# BartyCrouch

Expand Down Expand Up @@ -61,8 +71,8 @@ With BartyCrouch you can run commands like these:
# Incrementally updates all Strings files of Storyboards/XIBs in project
$ bartycrouch interfaces -p "/absolute/path/to/project"

# Updates all `Localizable.strings` files searching your code for `NSLocalizedString`
$ bartycrouch code -p "/path/to/code/directory" -l "/directory/containing/all/Localizables"
# Updates `Localizable.strings` files with new keys searching your code for `NSLocalizedString`
$ bartycrouch code -p "/path/to/code/directory" -l "/directory/containing/all/Localizables" -a

# Machine-translate all empty localization values using English as source language
$ bartycrouch translate -p "/path/to/project" -l en -i "<API_ID>" -s "<API_SECRET>"
Expand All @@ -77,10 +87,10 @@ Also you can make your life a lot easier by using the **build script method** de
The `bartycrouch` main command accepts one of the following sub commands:

- **`interfaces`:** Incrementally updates Strings files of localized Storyboards and XIBs.
- **`code`:** Incrementally updates `Localizable.strings` file from `.h`, `.m` and `.swift` files.
- **`code`:** Incrementally updates `Localizable.strings` files from `.h`, `.m` and `.swift` files.
- **`translate`:** Machine-translates values from a source Strings file to all other languages.

Note that *each sub command accepts a different set of options*. Some of them are **required** and some *optional*. You can **combine all options** with each other to create your own expected behavior. If you're not sure which options are available or required you can always look them up in terminal by running without options like so:
Note that *each sub command accepts a different set of options*. Some of them are **required** and some *optional*. You can **combine all options** with each other to create your own expected behavior. If you're not sure which options are available or required you can always look them up in terminal by running a sub command without options like so:

```shell
$ bartycrouch code
Expand Down Expand Up @@ -168,7 +178,7 @@ Here's an overview of all options available for the sub command `code`:
- `default-to-keys`
- `additive`

#### Localizable (aka `-l`, `--localizable`)
#### Localizable (aka `-l`, `--localizable`) <small>*required*</small>

Specifies the path to the directory which contains all `Localizable.strings` files within `<locale>.lproj` folders. BartyCrouch will search for all files named `Localizable.strings` recursively within the specified path and incrementally update them. Make sure to specify a path with only your projects `Localizable.strings` files.

Expand Down Expand Up @@ -273,7 +283,7 @@ It is recommended that you update the `-p "$PROJECT_DIR"` appearances in this sc

---

### Exclude specific Views from Localization
### Exclude specific Views / NSLocalizedStrings from Localization

Sometimes you may want to **ignore some specific views** containing localizable texts e.g. because **their values are gonna be set programmatically**.
For these cases you can simply include `#bartycrouch-ignore!` or the shorthand `#bc-ignore!` into your value within your base localized Storyboard/XIB file.
Expand All @@ -283,6 +293,15 @@ Here's an example of how a base localized view in a XIB file with partly ignored

<img src="Exclusion-Example.png">

You can also use `#bc-ignore!` in your `NSLocalizedString` macros comment part to ignore them so they are not added to your `Localizable.strings`. This is helpful when you are using a `.stringsdict` file to handle pluralization (see [docs](https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/StringsdictFileFormat/StringsdictFileFormat.html)).

For example you can do something like this:
```swift
func updateTimeLabel(minutes: Int) {
String.localizedStringWithFormat(NSLocalizedString("%d minute(s) ago", comment: "pluralized and localized minutes #bc-ignore!"), minutes)
}
```
The `%d minute(s) ago` key will be taken from Localizable.stringsdict file, not from Localizable.strings.

## Migration Guides

Expand Down
2 changes: 1 addition & 1 deletion Sources/Code/CommandLineActor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class CommandLineActor {

private func actOnCode(path path: String, override: Bool, verbose: Bool, localizable: String, defaultToKeys: Bool, additive: Bool) {

let allLocalizableStringsFilePaths = StringsFilesSearch.sharedInstance.findAllStringsFiles(path, withFileName: "Localizable")
let allLocalizableStringsFilePaths = StringsFilesSearch.sharedInstance.findAllStringsFiles(localizable, withFileName: "Localizable")

guard !allLocalizableStringsFilePaths.isEmpty else {
self.printError("No `Localizable.strings` file found for output.")
Expand Down
9 changes: 7 additions & 2 deletions Sources/Code/StringsFileUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class StringsFileUpdater {

/// Updates the keys of this instances strings file with those of the given strings file.
/// Note that this will add new keys, remove not-existing keys but won't touch any existing ones.
public func incrementallyUpdateKeys(withStringsFileAtPath otherStringFilePath: String, addNewValuesAsEmpty: Bool, ignoreBaseKeys: [String] = ["#bartycrouch-ignore!", "#bc-ignore!", "#i!"], override: Bool = false, updateCommentWithBase: Bool = true, keepExistingKeys: Bool = false) {
public func incrementallyUpdateKeys(withStringsFileAtPath otherStringFilePath: String, addNewValuesAsEmpty: Bool, ignoreBaseKeysAndComment ignores: [String] = ["#bartycrouch-ignore!", "#bc-ignore!", "#i!"], override: Bool = false, updateCommentWithBase: Bool = true, keepExistingKeys: Bool = false) {

do {
let newContentString = try String(contentsOfFile: otherStringFilePath)
Expand Down Expand Up @@ -61,7 +61,12 @@ public class StringsFileUpdater {
for (key, newValue, newComment) in newTranslations {

// skip keys marked for ignore
guard !newValue.containsAny(ofStrings: ignoreBaseKeys) else {
guard !newValue.containsAny(ofStrings: ignores) else {
continue
}

// Skip keys that have been marked for ignore in comment
if let newComment = newComment where newComment.containsAny(ofStrings: ignores) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Supporting Files/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>3.0.0</string>
<string>3.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 1 addition & 0 deletions Tests/Assets/CodeFiles/Subfolder/SwiftExample2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SwiftExample2 {

NSLocalizedString("TestKey2", comment: "Comment for TestKey1")
String(format: NSLocalizedString("%010d and %03.f", comment: ""), 25, 89.5)
String.localizableStringWithFormat(NSLocalizedString("%d ignore(s)", comment: "Ignoring stringsdict key #bc-ignore!"), 25)

}

Expand Down
3 changes: 3 additions & 0 deletions Tests/Code/GenStringsCommanderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class GenStringsCommanderTests: XCTestCase {
"/* No comment provided by engineer. */",
"\"%@ and %.2f\" = \"%1$@ and %2$.2f\";",
"",
"/* Ignoring stringsdict key #bc-ignore! */",
"\"%d ignore(s)\" = \"%d ignore(s)\";",
"",
"/* Comment for TestKey1 */",
"\"TestKey1\" = \"TestKey1\";",
"",
Expand Down

0 comments on commit 7999add

Please sign in to comment.