From 80d54322581d28bced3536043d9cec9af86c59cb Mon Sep 17 00:00:00 2001 From: Tomasz Szulc Date: Sat, 1 Aug 2015 17:52:50 +0200 Subject: [PATCH 1/4] Convert project to Swift 2 --- .../InequalityExpressionParser.swift | 4 ++-- Swifternalization/JSONFileLoader.swift | 16 ++++++++++------ Swifternalization/Regex.swift | 18 +++++++++--------- Swifternalization/RegexExpressionParser.swift | 2 +- .../SharedExpressionsProcessor.swift | 2 +- Swifternalization/Swifternalization.swift | 4 ++-- Swifternalization/Translation.swift | 2 +- Swifternalization/TranslationsLoader.swift | 4 ++-- .../LoadedTranslationsProcessorTests.swift | 10 +++++----- SwifternalizationTests/RandomNumbers.swift | 8 ++++---- .../SwifternalizationTests.swift | 2 +- 11 files changed, 38 insertions(+), 34 deletions(-) diff --git a/Swifternalization/InequalityExpressionParser.swift b/Swifternalization/InequalityExpressionParser.swift index 5d692e1..2af5d8d 100644 --- a/Swifternalization/InequalityExpressionParser.swift +++ b/Swifternalization/InequalityExpressionParser.swift @@ -71,7 +71,7 @@ class InequalityExpressionParser: ExpressionParser { if let value = Regex.matchInString(pattern, pattern: regex, capturingGroupIdx: capturingGroupIdx) { return NSString(string: value).doubleValue } else { - println("\(failureMessage), pattern: \(pattern), regex: \(regex)") + print("\(failureMessage), pattern: \(pattern), regex: \(regex)") return nil } } @@ -89,7 +89,7 @@ class InequalityExpressionParser: ExpressionParser { let sign = InequalitySign(rawValue: rawValue) { return sign } else { - println("\(failureMessage), pattern: \(pattern), regex: \(regex)") + print("\(failureMessage), pattern: \(pattern), regex: \(regex)") return nil } } diff --git a/Swifternalization/JSONFileLoader.swift b/Swifternalization/JSONFileLoader.swift index cd24d65..4a916a2 100644 --- a/Swifternalization/JSONFileLoader.swift +++ b/Swifternalization/JSONFileLoader.swift @@ -44,7 +44,7 @@ final class JSONFileLoader { if let fileURL = bundle.URLForResource(fileName, withExtension: "json") { return load(fileURL) } - println("Cannot find file \(fileName).json.") + print("Cannot find file \(fileName).json.") return nil } @@ -56,12 +56,16 @@ final class JSONFileLoader { */ private class func load(fileURL: NSURL) -> JSONDictionary? { if let data = NSData(contentsOfURL: fileURL) { - var error: NSError? - if let dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.allZeros, error: &error) as? JSONDictionary { - return dictionary + do { + if let dictionary = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as? JSONDictionary { + return dictionary + } + print("Cannot parse JSON. It might be broken.") + return nil + } catch { + print("Cannot parse JSON. It might be broken.") + return nil } - print("Cannot parse JSON. It might be broken.") - return nil } print("Cannot load content of file.") return nil diff --git a/Swifternalization/Regex.swift b/Swifternalization/Regex.swift index 9c12be7..b0857bb 100644 --- a/Swifternalization/Regex.swift +++ b/Swifternalization/Regex.swift @@ -23,8 +23,8 @@ final class Regex { class func matchInString(str: String, pattern: String, capturingGroupIdx: Int?) -> String? { var resultString: String? - let range = NSMakeRange(0, count(str)) - regexp(pattern)?.enumerateMatchesInString(str, options: nil, range: range, usingBlock: { result, flags, stop in + let range = NSMakeRange(0, distance(str.startIndex, str.endIndex)) + regexp(pattern)?.enumerateMatchesInString(str, options: NSMatchingOptions.ReportCompletion, range: range, usingBlock: { result, flags, stop in if let result = result { if let capturingGroupIdx = capturingGroupIdx where result.numberOfRanges > capturingGroupIdx { resultString = self.substring(str, range: result.rangeAtIndex(capturingGroupIdx)) @@ -46,7 +46,7 @@ final class Regex { :returns: `String` that matches pattern or nil. */ class func firstMatchInString(str: String, pattern: String) -> String? { - if let result = regexp(pattern)?.firstMatchInString(str, options: .ReportCompletion, range: NSMakeRange(0, count(str))) { + if let result = regexp(pattern)?.firstMatchInString(str, options: .ReportCompletion, range: NSMakeRange(0, distance(str.startIndex, str.endIndex))) { return substring(str, range: result.range) } return nil @@ -61,7 +61,7 @@ final class Regex { */ class func matchesInString(str: String, pattern: String) -> [String] { var matches = [String]() - if let results = regexp(pattern)?.matchesInString(str, options: .ReportCompletion, range: NSMakeRange(0, count(str))) as? [NSTextCheckingResult] { + if let results = regexp(pattern)?.matchesInString(str, options: .ReportCompletion, range: NSMakeRange(0, distance(str.startIndex, str.endIndex))) { for result in results { matches.append(substring(str, range: result.range)) } @@ -77,12 +77,12 @@ final class Regex { :returns: `NSRegularExpression` object or nil if it cannot be created. */ private class func regexp(pattern: String) -> NSRegularExpression? { - var error: NSError? = nil - var regexp = NSRegularExpression(pattern: pattern, options: .CaseInsensitive, error: &error) - if error != nil { - println(error!) + do { + return try NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.CaseInsensitive) + } catch let error as NSError { + print(error) } - return regexp + return nil } /** diff --git a/Swifternalization/RegexExpressionParser.swift b/Swifternalization/RegexExpressionParser.swift index 2a004d7..4a5b050 100644 --- a/Swifternalization/RegexExpressionParser.swift +++ b/Swifternalization/RegexExpressionParser.swift @@ -50,7 +50,7 @@ class RegexExpressionParser: ExpressionParser { if let regex = Regex.firstMatchInString(pattern, pattern: "(?<=^\(ExpressionPatternType.Regex.rawValue):).*") { return regex } else { - println("Cannot find any regular expression, pattern: \(pattern)") + print("Cannot find any regular expression, pattern: \(pattern)") return nil } } diff --git a/Swifternalization/SharedExpressionsProcessor.swift b/Swifternalization/SharedExpressionsProcessor.swift index c132939..534969b 100644 --- a/Swifternalization/SharedExpressionsProcessor.swift +++ b/Swifternalization/SharedExpressionsProcessor.swift @@ -55,7 +55,7 @@ class SharedExpressionsProcessor { let uniqueBaseExpressions = baseLanguageExpressions CountryCode { // Get preferred language, the one which is set on user's device - return bundle.preferredLocalizations.first as! CountryCode + return bundle.preferredLocalizations.first! as CountryCode } } diff --git a/Swifternalization/Translation.swift b/Swifternalization/Translation.swift index 89840f0..8adc1f0 100644 --- a/Swifternalization/Translation.swift +++ b/Swifternalization/Translation.swift @@ -44,7 +44,7 @@ struct Translation { If variation width is shorter or equal `fittingWidth` take associated value. */ - for variation in expression.lengthVariations.sorted({$0.width < $1.width}) { + for variation in expression.lengthVariations.sort({$0.width < $1.width}) { if variation.width <= fittingWidth! { localizedValue = variation.value } diff --git a/Swifternalization/TranslationsLoader.swift b/Swifternalization/TranslationsLoader.swift index 8af250c..20b3ec3 100644 --- a/Swifternalization/TranslationsLoader.swift +++ b/Swifternalization/TranslationsLoader.swift @@ -22,7 +22,7 @@ final class TranslationsLoader { if let type = detectElementType(dictionary) { loadedTranslations.append(LoadedTranslation(type: type, key: key, content: dictionary)) } else { - println("Translation type is not supported for: \(dictionary)") + print("Translation type is not supported for: \(dictionary)") } } } @@ -42,7 +42,7 @@ final class TranslationsLoader { var strings = 0 // Count every string or dict occurence. - for (key, value) in element { + for (_, value) in element { if value is String { strings++ } else if value is Dictionary { diff --git a/SwifternalizationTests/LoadedTranslationsProcessorTests.swift b/SwifternalizationTests/LoadedTranslationsProcessorTests.swift index 4059782..0370468 100644 --- a/SwifternalizationTests/LoadedTranslationsProcessorTests.swift +++ b/SwifternalizationTests/LoadedTranslationsProcessorTests.swift @@ -72,7 +72,7 @@ class LoadedTranslationsProcessorTests: XCTestCase { let enTranslations = TranslationsLoader.loadTranslations(_enTranslations()) var translations = LoadedTranslationsProcessor.processTranslations(baseTranslations, preferedLanguageTranslations: enTranslations, sharedExpressions: expressions) - translations.sort({$0.key < $1.key}) + translations.sortInPlace({$0.key < $1.key}) XCTAssertEqual(translations.count, 4, "") @@ -99,10 +99,10 @@ class LoadedTranslationsProcessorTests: XCTestCase { // Get patterns of expressions var k3ExpressionPatterns: [String] = k3Translation.expressions.map({ $0.pattern }) - k3ExpressionPatterns.sort({$0 < $1}) + k3ExpressionPatterns.sortInPlace({$0 < $1}) var k3ExpressionsToMatch: [String] = [_enExpressions()["e1"]!, _enExpressions()["e2"]!] - k3ExpressionsToMatch.sort({$0 < $1}) + k3ExpressionsToMatch.sortInPlace({$0 < $1}) XCTAssertEqual(k3ExpressionPatterns, k3ExpressionsToMatch, "") @@ -115,10 +115,10 @@ class LoadedTranslationsProcessorTests: XCTestCase { // Get patterns of expressions var k4ExpressionPatterns: [String] = k4Translation.expressions.map({ $0.pattern }) - k4ExpressionPatterns.sort({$0 < $1}) + k4ExpressionPatterns.sortInPlace({$0 < $1}) var k4ExpressionsToMatch: [String] = [_enExpressions()["e2"]!, _enExpressions()["e3"]!, _enExpressions()["e4"]!] - k4ExpressionsToMatch.sort({$0 < $1}) + k4ExpressionsToMatch.sortInPlace({$0 < $1}) XCTAssertEqual(k4ExpressionPatterns, k4ExpressionsToMatch, "") } diff --git a/SwifternalizationTests/RandomNumbers.swift b/SwifternalizationTests/RandomNumbers.swift index c9d5996..25d613f 100644 --- a/SwifternalizationTests/RandomNumbers.swift +++ b/SwifternalizationTests/RandomNumbers.swift @@ -16,20 +16,20 @@ func arc4random (type: T.Type) -> T { } extension Float { - static func random(#lower: Float, upper: Float) -> Float { + static func random(lower lower: Float, upper: Float) -> Float { let r = Float(arc4random(UInt32)) / Float(UInt32.max) return (r * (upper - lower)) + lower } - static func randomNumbers(#lower: Float, upper: Float, count: Int) -> [Float] { + static func randomNumbers(lower lower: Float, upper: Float, count: Int) -> [Float] { var nums = [Float]() - for i in 0.. [String] { + static func randomNumbersStrings(lower lower: Float, upper: Float, count: Int) -> [String] { var numStr = [String]() for i in randomNumbers(lower: lower, upper: upper, count: count) { numStr.append(String(format: "%f", i)) diff --git a/SwifternalizationTests/SwifternalizationTests.swift b/SwifternalizationTests/SwifternalizationTests.swift index e466c9b..cda6639 100644 --- a/SwifternalizationTests/SwifternalizationTests.swift +++ b/SwifternalizationTests/SwifternalizationTests.swift @@ -14,7 +14,7 @@ class SwifternalizationTests: XCTestCase { override func setUp() { super.setUp() - Swifternalization.configure(bundle: NSBundle.testBundle()) + Swifternalization.configure(NSBundle.testBundle()) } func testShouldReturnKeyWhenNotTranslated() { From 775b5199f2a576e40d5eb63b09ea4c9e3b963f75 Mon Sep 17 00:00:00 2001 From: Tomasz Szulc Date: Sat, 1 Aug 2015 17:58:29 +0200 Subject: [PATCH 2/4] Cleanup in project structure --- ExpressionsLoader.playground/Contents.swift | 11 -- .../Resources/base.json | 28 ----- .../Resources/expressions.json | 11 -- .../Sources/CountryCode.swift | 8 -- .../ExpressionRepresentationType.swift | 9 -- .../Sources/ExpressionsLoader.swift | 27 ----- .../Sources/ExpressionsPatternType.swift | 11 -- .../Sources/JSONFileLoader.swift | 45 -------- .../Sources/LengthVariation.swift | 18 --- .../Sources/LengthVariationType.swift | 10 -- .../Sources/Processable.swift | 12 -- .../Sources/ProcessableExpression.swift | 18 --- ...ProcessableLengthVariationExpression.swift | 18 --- .../Sources/ProcessableTranslation.swift | 18 --- ...TranslationLengthVariationExpression.swift | 18 --- .../Sources/Regex.swift | 106 ------------------ .../Sources/TranslationLengthVariation.swift | 18 --- .../Sources/TranslationSimple.swift | 18 --- .../Sources/TranslationType.swift | 9 -- .../Sources/TranslationsLoader.swift | 103 ----------------- .../contents.xcplayground | 4 - .../contents.xcworkspacedata | 7 -- .../UserInterfaceState.xcuserstate | Bin 27792 -> 0 bytes .../WorkspaceSettings.xcsettings | 10 -- .../timeline.xctimeline | 6 - Swifternalization.xcodeproj/project.pbxproj | 36 +++--- .../SharedBaseExpression.swift | 0 .../SharedPolishExpression.swift | 0 28 files changed, 18 insertions(+), 561 deletions(-) delete mode 100644 ExpressionsLoader.playground/Contents.swift delete mode 100644 ExpressionsLoader.playground/Resources/base.json delete mode 100644 ExpressionsLoader.playground/Resources/expressions.json delete mode 100644 ExpressionsLoader.playground/Sources/CountryCode.swift delete mode 100644 ExpressionsLoader.playground/Sources/ExpressionRepresentationType.swift delete mode 100644 ExpressionsLoader.playground/Sources/ExpressionsLoader.swift delete mode 100644 ExpressionsLoader.playground/Sources/ExpressionsPatternType.swift delete mode 100644 ExpressionsLoader.playground/Sources/JSONFileLoader.swift delete mode 100644 ExpressionsLoader.playground/Sources/LengthVariation.swift delete mode 100644 ExpressionsLoader.playground/Sources/LengthVariationType.swift delete mode 100644 ExpressionsLoader.playground/Sources/Processable.swift delete mode 100644 ExpressionsLoader.playground/Sources/ProcessableExpression.swift delete mode 100644 ExpressionsLoader.playground/Sources/ProcessableLengthVariationExpression.swift delete mode 100644 ExpressionsLoader.playground/Sources/ProcessableTranslation.swift delete mode 100644 ExpressionsLoader.playground/Sources/ProcessableTranslationLengthVariationExpression.swift delete mode 100644 ExpressionsLoader.playground/Sources/Regex.swift delete mode 100644 ExpressionsLoader.playground/Sources/TranslationLengthVariation.swift delete mode 100644 ExpressionsLoader.playground/Sources/TranslationSimple.swift delete mode 100644 ExpressionsLoader.playground/Sources/TranslationType.swift delete mode 100644 ExpressionsLoader.playground/Sources/TranslationsLoader.swift delete mode 100644 ExpressionsLoader.playground/contents.xcplayground delete mode 100644 ExpressionsLoader.playground/playground.xcworkspace/contents.xcworkspacedata delete mode 100644 ExpressionsLoader.playground/playground.xcworkspace/xcuserdata/tomkowz.xcuserdatad/UserInterfaceState.xcuserstate delete mode 100644 ExpressionsLoader.playground/playground.xcworkspace/xcuserdata/tomkowz.xcuserdatad/WorkspaceSettings.xcsettings delete mode 100644 ExpressionsLoader.playground/timeline.xctimeline rename Swifternalization/{Shared Expressions => }/SharedBaseExpression.swift (100%) rename Swifternalization/{Shared Expressions => }/SharedPolishExpression.swift (100%) diff --git a/ExpressionsLoader.playground/Contents.swift b/ExpressionsLoader.playground/Contents.swift deleted file mode 100644 index 642a8c5..0000000 --- a/ExpressionsLoader.playground/Contents.swift +++ /dev/null @@ -1,11 +0,0 @@ -//: Playground - noun: a place where people can play - -import UIKit - -let expsBase = ExpressionsLoader.loadExpressions("base") -let expsPL = ExpressionsLoader.loadExpressions("pl") -let translations = TranslationsLoader.loadTranslations("base") - -for translation in translations { - println(translation.key) -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Resources/base.json b/ExpressionsLoader.playground/Resources/base.json deleted file mode 100644 index e0b4524..0000000 --- a/ExpressionsLoader.playground/Resources/base.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "welcome": "welcome", - - "cars": { - "one": "1 car", - "ie:x=2": "2 cars", - "more": "%d cars" - }, - - "forgot-password": { - "@100": "Forgot Password? Help.", - "@200": "Forgot Password? Get password Help.", - "@300": "Forgotten Your Password? Get password Help." - }, - - "car-sentence": { - "one": { - "@100": "one car", - "@200": "just one car", - "@300": "you've got just one car" - }, - - "more": { - "@100": "%d cars", - "@300": "you've got %d cars" - } - } -} diff --git a/ExpressionsLoader.playground/Resources/expressions.json b/ExpressionsLoader.playground/Resources/expressions.json deleted file mode 100644 index 05f0b5d..0000000 --- a/ExpressionsLoader.playground/Resources/expressions.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "base": { - "one": "ie:x=1", - "two": "ie:x=2", - "more": "exp:(^[^1])|(^\\d{2,})" - }, - - "pl": { - "few": "exp:(((?!1).[2-4]{1})$)|(^[2-4]$)" - } -} diff --git a/ExpressionsLoader.playground/Sources/CountryCode.swift b/ExpressionsLoader.playground/Sources/CountryCode.swift deleted file mode 100644 index 05a482c..0000000 --- a/ExpressionsLoader.playground/Sources/CountryCode.swift +++ /dev/null @@ -1,8 +0,0 @@ -import Foundation - -/** -https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 (lowercase) + "base" -Represents country codes in framework. -Country codes are used to get correct user device's language. -*/ -public typealias CountryCode = String diff --git a/ExpressionsLoader.playground/Sources/ExpressionRepresentationType.swift b/ExpressionsLoader.playground/Sources/ExpressionRepresentationType.swift deleted file mode 100644 index 1703518..0000000 --- a/ExpressionsLoader.playground/Sources/ExpressionRepresentationType.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation - -/** -Represents expressions in the framework. -*/ -public protocol ExpressionRepresentationType { - /// Identifier of expression. - var identifier: String {get} -} diff --git a/ExpressionsLoader.playground/Sources/ExpressionsLoader.swift b/ExpressionsLoader.playground/Sources/ExpressionsLoader.swift deleted file mode 100644 index da50f07..0000000 --- a/ExpressionsLoader.playground/Sources/ExpressionsLoader.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation - -/** -Used to load content from `expressions.json` file for specified language. -*/ -public final class ExpressionsLoader: JSONFileLoader { - - /** - Loads expressions for specified language. - - :param: countryCode A country code - - :returns: array of loaded expressions. - */ - public class func loadExpressions(countryCode: CountryCode) -> [ProcessableExpression] { - var expressions = [ProcessableExpression]() - if let json = self.load("expressions", fileType: "json", bundle: NSBundle.mainBundle()), - let expressionsDict = json[countryCode] as? Dictionary { - for (identifier, pattern) in expressionsDict { - expressions.append(ProcessableExpression(identifier: identifier, pattern: pattern)) - } - } else { - println("expressions.json file structure is incorrect.") - } - return expressions - } -} diff --git a/ExpressionsLoader.playground/Sources/ExpressionsPatternType.swift b/ExpressionsLoader.playground/Sources/ExpressionsPatternType.swift deleted file mode 100644 index 7babb8d..0000000 --- a/ExpressionsLoader.playground/Sources/ExpressionsPatternType.swift +++ /dev/null @@ -1,11 +0,0 @@ -import Foundation - -/** -Represents objects that have expression pattern. -Example an expression that contains just pattern, without things like length -variations. -*/ -public protocol ExpressionPatternType { - /// A pattern. - var pattern: String {get} -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/JSONFileLoader.swift b/ExpressionsLoader.playground/Sources/JSONFileLoader.swift deleted file mode 100644 index e5e4884..0000000 --- a/ExpressionsLoader.playground/Sources/JSONFileLoader.swift +++ /dev/null @@ -1,45 +0,0 @@ -import Foundation - -/** -Simple JSON loader. -*/ -public class JSONFileLoader { - public typealias JSONDictionary = Dictionary - - /** - Load content of file with specified name, type and bundle. - - :param: fileName A name of a file. - :param: fileType A type of a file. - :param: bundle A bundle when file is located. - - :return: JSON or nil. - */ - public final class func load(fileName: String, fileType: String, bundle: NSBundle = NSBundle.mainBundle()) -> JSONDictionary? { - if let fileURL = bundle.URLForResource(fileName, withExtension: fileType) { - return load(fileURL) - } - println("Cannot find file \(fileName).\(fileType).") - return nil - } - - /** - Loads file for specified URL and try to serialize it. - - :params: fileURL url to JSON file. - - :return: Dictionary with content of JSON file or nil. - */ - private class func load(fileURL: NSURL) -> JSONDictionary? { - if let data = NSData(contentsOfURL: fileURL) { - var error: NSError? - if let dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.allZeros, error: &error) as? JSONDictionary { - return dictionary - } else { - print("Cannot parse JSON. It might be broken.") - } - } - print("Cannot load content of file.") - return nil - } -} diff --git a/ExpressionsLoader.playground/Sources/LengthVariation.swift b/ExpressionsLoader.playground/Sources/LengthVariation.swift deleted file mode 100644 index beadc32..0000000 --- a/ExpressionsLoader.playground/Sources/LengthVariation.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Struct that represents length variation. -*/ -public struct LengthVariation: LengthVariationType { - /// Length - width of a screen. - public let length: Int - - /// localized string. - public let value: String - - /// Create length variation object. - public init(length: Int, value: String) { - self.length = length - self.value = value - } -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/LengthVariationType.swift b/ExpressionsLoader.playground/Sources/LengthVariationType.swift deleted file mode 100644 index 0959ff2..0000000 --- a/ExpressionsLoader.playground/Sources/LengthVariationType.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -/// Represents length variation. -public protocol LengthVariationType { - /// Length of a screen. - var length: Int {get} - - /// Localized value. - var value: String {get} -} diff --git a/ExpressionsLoader.playground/Sources/Processable.swift b/ExpressionsLoader.playground/Sources/Processable.swift deleted file mode 100644 index 4deef2a..0000000 --- a/ExpressionsLoader.playground/Sources/Processable.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Foundation - -/** -Specifies objects that need processing and are not final objects that can be -used in the framework. An example of such object might be `ProcessableExpression` -that is not ready to be used because it has to be converted into normal kind of -expression that has its fields correctly filled. - -Another good example is `TranslationType` object that contains expression or few -that need to be processed. -*/ -protocol Processable {} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/ProcessableExpression.swift b/ExpressionsLoader.playground/Sources/ProcessableExpression.swift deleted file mode 100644 index a0c0bac..0000000 --- a/ExpressionsLoader.playground/Sources/ProcessableExpression.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Represents loaded expression that will be processed later. -*/ -public struct ProcessableExpression: ExpressionRepresentationType, ExpressionPatternType, Processable { - /// Identifier of expression. - public let identifier: String - - /// Pattern of expression. - public let pattern: String - - /// Creates expression. - public init(identifier: String, pattern: String) { - self.identifier = identifier - self.pattern = pattern - } -} diff --git a/ExpressionsLoader.playground/Sources/ProcessableLengthVariationExpression.swift b/ExpressionsLoader.playground/Sources/ProcessableLengthVariationExpression.swift deleted file mode 100644 index 77c84f5..0000000 --- a/ExpressionsLoader.playground/Sources/ProcessableLengthVariationExpression.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Represents processable expression with length variations. -*/ -public struct ProcessableLengthVariationExpression: ExpressionRepresentationType, Processable { - /// Identifier of expression. - public var identifier: String - - /// Array of length variations - var variations: [LengthVariation] - - /// Creates instance of the class. - public init(identifier: String, variations: [LengthVariation]) { - self.identifier = identifier - self.variations = variations - } -} diff --git a/ExpressionsLoader.playground/Sources/ProcessableTranslation.swift b/ExpressionsLoader.playground/Sources/ProcessableTranslation.swift deleted file mode 100644 index 6c9725d..0000000 --- a/ExpressionsLoader.playground/Sources/ProcessableTranslation.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Represents translation which contains expressions that are not processed yet. -*/ -public struct ProcessableTranslation: TranslationType, Processable { - /// Key that identifies translation. - public let key: String - - /// Array with loaded expressions. - let loadedExpressions: [ProcessableExpression] - - /// Creates instances of the class. - public init(key: String, loadedExpressions: [ProcessableExpression]) { - self.key = key - self.loadedExpressions = loadedExpressions - } -} diff --git a/ExpressionsLoader.playground/Sources/ProcessableTranslationLengthVariationExpression.swift b/ExpressionsLoader.playground/Sources/ProcessableTranslationLengthVariationExpression.swift deleted file mode 100644 index 092aa1f..0000000 --- a/ExpressionsLoader.playground/Sources/ProcessableTranslationLengthVariationExpression.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Represents translation which contains expressions with length variations. -*/ -public struct ProcessableTranslationLengthVariationExpression: TranslationType, Processable { - /// Key that identifies translation. - public let key: String - - /// Array with expressions. - let expressions: [ProcessableLengthVariationExpression] - - /// Creates instances of the class. - public init(key: String, expressions: [ProcessableLengthVariationExpression]) { - self.key = key - self.expressions = expressions - } -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/Regex.swift b/ExpressionsLoader.playground/Sources/Regex.swift deleted file mode 100644 index 91717ca..0000000 --- a/ExpressionsLoader.playground/Sources/Regex.swift +++ /dev/null @@ -1,106 +0,0 @@ -// -// Regex.swift -// Swifternalization -// -// Created by Tomasz Szulc on 27/06/15. -// Copyright (c) 2015 Tomasz Szulc. All rights reserved. -// - -import Foundation - -/** -Class uses NSRegularExpression internally and simplifies its usability. -*/ -public class Regex { - - /** - Return match in a string. Optionally with index of capturing group - - :param: str A string that will be matched. - :param: pattern A regex pattern. - - :returns: `String` that matches pattern or nil. - */ - public class func matchInString(str: String, pattern: String, capturingGroupIdx: Int?) -> String? { - var resultString: String? - - let range = NSMakeRange(0, count(str)) - regexp(pattern)?.enumerateMatchesInString(str, options: nil, range: range, usingBlock: { result, flags, stop in - if let result = result { - if let capturingGroupIdx = capturingGroupIdx where result.numberOfRanges > capturingGroupIdx { - resultString = self.substring(str, range: result.rangeAtIndex(capturingGroupIdx)) - } else { - resultString = self.substring(str, range: result.range) - } - } - }) - - return resultString - } - - - /** - Return first match in a string. - - :param: str A string that will be matched. - :param: pattern A regexp pattern. - - :returns: `String` that matches pattern or nil. - */ - class func firstMatchInString(str: String, pattern: String) -> String? { - if let result = regexp(pattern)?.firstMatchInString(str, options: .ReportCompletion, range: NSMakeRange(0, count(str))) { - return substring(str, range: result.range) - } - return nil - } - - /** - Return all matches in a string. - - :param: str A string that will be matched. - :param: pattern A regexp pattern. - - :returns: Array of `Strings`s. If nothing found empty array is returned. - */ - class func matchesInString(str: String, pattern: String) -> [String] { - var matches = [String]() - if let results = regexp(pattern)?.matchesInString(str, options: .ReportCompletion, range: NSMakeRange(0, count(str))) as? [NSTextCheckingResult] { - for result in results { - matches.append(substring(str, range: result.range)) - } - } - - return matches - } - - /** - Returns new `NSRegularExpression` object. - - :param: pattern A regexp pattern. - - :returns: `NSRegularExpression` object or nil if it cannot be created. - */ - private class func regexp(pattern: String) -> NSRegularExpression? { - var error: NSError? = nil - var regexp = NSRegularExpression(pattern: pattern, options: .CaseInsensitive, error: &error) - if error != nil { - println(error!) - } - return regexp - } - - /** - Method that substring string with passed range. - - :param: str A string that is source of substraction. - :param: range A range that tells which part of `str` will be substracted. - - :returns: A string contained in `range`. - */ - private class func substring(str: String, range: NSRange) -> String { - let startRange = advance(str.startIndex, range.location) - let endRange = advance(startRange, range.length) - - return str.substringWithRange(Range(start: startRange, end: endRange)) - } -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/TranslationLengthVariation.swift b/ExpressionsLoader.playground/Sources/TranslationLengthVariation.swift deleted file mode 100644 index 95688c1..0000000 --- a/ExpressionsLoader.playground/Sources/TranslationLengthVariation.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Class represents translation which contains key and length variations. -*/ -public struct TranslationLengthVariation: TranslationType { - /// Key that identifies this translation. - public let key: String - - /// list of variations. - let variations: [LengthVariation] - - /// Creates translation object - public init(key: String, variations: [LengthVariation]) { - self.key = key - self.variations = variations - } -} \ No newline at end of file diff --git a/ExpressionsLoader.playground/Sources/TranslationSimple.swift b/ExpressionsLoader.playground/Sources/TranslationSimple.swift deleted file mode 100644 index 83305cd..0000000 --- a/ExpressionsLoader.playground/Sources/TranslationSimple.swift +++ /dev/null @@ -1,18 +0,0 @@ -import Foundation - -/** -Represents simple key-value translation. -*/ -public struct TranslationSimple: TranslationType { - /// Key that identifies translation. - public let key: String - - /// Localized string. - public let value: String - - /// Creates instance of the class. - public init(key: String, value: String) { - self.key = key - self.value = value - } -} diff --git a/ExpressionsLoader.playground/Sources/TranslationType.swift b/ExpressionsLoader.playground/Sources/TranslationType.swift deleted file mode 100644 index 653d598..0000000 --- a/ExpressionsLoader.playground/Sources/TranslationType.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation - -/** -Represents translation. -*/ -public protocol TranslationType { - /// Key that identifies translation. - var key: String {get} -} diff --git a/ExpressionsLoader.playground/Sources/TranslationsLoader.swift b/ExpressionsLoader.playground/Sources/TranslationsLoader.swift deleted file mode 100644 index 83a97ef..0000000 --- a/ExpressionsLoader.playground/Sources/TranslationsLoader.swift +++ /dev/null @@ -1,103 +0,0 @@ -import Foundation - -/** -Represents translations loader. -Class is looking for json file named as country code. -It parse such file. -*/ -public final class TranslationsLoader: JSONFileLoader { - - typealias DictWithStrings = Dictionary - typealias DictWithDicts = Dictionary - - enum ElementType { - case NotSupported - case TranslationWithLengthVariations - case TranslationWithLoadedExpressions - case TranslationWithLengthVariationsAndLoadedExpressions - } - - /** - Method loads a file and parses it. - - :params: countryCode A country code. - - :return: translations parsed from the file. - */ - public class func loadTranslations(countryCode: CountryCode) -> [TranslationType] { - var loadedTranslations = [TranslationType]() - let json = self.load(countryCode, fileType: "json", bundle: NSBundle.mainBundle()) - if json == nil { return [TranslationType]() } - - for (translationKey, value) in json! { - if let translationValue = value as? String { - loadedTranslations.append(TranslationSimple(key: translationKey, value: translationValue)) - } else { - let dictionary = value as! JSONDictionary - switch detectElementType(dictionary) { - case .TranslationWithLengthVariations: - let variations = parseLengthVariations(dictionary as! DictWithStrings) - loadedTranslations.append(TranslationLengthVariation(key: translationKey, variations: variations)) - - case .TranslationWithLoadedExpressions: - let expressions = parseExpressions(dictionary as! DictWithStrings) - loadedTranslations.append(ProcessableTranslation(key: translationKey, loadedExpressions: expressions)) - - case .TranslationWithLengthVariationsAndLoadedExpressions: - var expressions = [ProcessableLengthVariationExpression]() - for (expressionIdentifier, lengthVariationsDict) in dictionary as! DictWithDicts { - let variations = parseLengthVariations(lengthVariationsDict) - expressions.append(ProcessableLengthVariationExpression(identifier: expressionIdentifier, variations: variations)) - } - loadedTranslations.append(ProcessableTranslationLengthVariationExpression(key: translationKey, expressions: expressions)) - - case .NotSupported: - // Do nothing - continue - } - } - } - - return loadedTranslations - } - - private class func parseLengthVariations(dict: DictWithStrings) -> [LengthVariation] { - var variations = [LengthVariation]() - for (key, translationValue) in dict { - let numberValue = parseNumberFromLengthVariation(key) - variations.append(LengthVariation(length: numberValue, value: translationValue)) - } - return variations - } - - private class func parseExpressions(dict: DictWithStrings) -> [ProcessableExpression] { - var expressions = [ProcessableExpression]() - for (expressionKey, translationValue) in dict { - expressions.append(ProcessableExpression(identifier: expressionKey, pattern: translationValue)) - } - return expressions - } - - private class func detectElementType(element: JSONDictionary) -> ElementType { - - if element is DictWithStrings { - if let key = element.keys.first { - let toIndex = advance(key.startIndex, 1) - let firstCharacter = key.substringToIndex(toIndex) - if firstCharacter == "@" { - return .TranslationWithLengthVariations - } else { - return .TranslationWithLoadedExpressions - } - } - } else if element is DictWithDicts { - return .TranslationWithLengthVariationsAndLoadedExpressions - } - - return .NotSupported - } - - private class func parseNumberFromLengthVariation(string: String) -> Int { - return (Regex.matchInString(string, pattern: "@(\\d+)", capturingGroupIdx: 1)! as NSString).integerValue - } -} diff --git a/ExpressionsLoader.playground/contents.xcplayground b/ExpressionsLoader.playground/contents.xcplayground deleted file mode 100644 index 5da2641..0000000 --- a/ExpressionsLoader.playground/contents.xcplayground +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ExpressionsLoader.playground/playground.xcworkspace/contents.xcworkspacedata b/ExpressionsLoader.playground/playground.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index c706b0d..0000000 --- a/ExpressionsLoader.playground/playground.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/ExpressionsLoader.playground/playground.xcworkspace/xcuserdata/tomkowz.xcuserdatad/UserInterfaceState.xcuserstate b/ExpressionsLoader.playground/playground.xcworkspace/xcuserdata/tomkowz.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index f98a0d1a491086015b2c3be74c87396706570b72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal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FGVT?qj)+ z=N`{Jn|nU@joi0$FXg_M`-iQEO=0V68(j&a(XWpFIUncK`CPtNey@B*{;>Sv`6Kd2=Iin! z@>BBD^Rx1E@{96I@~iV3@|*JK=9Byd`S<4Em%luJW&Y~?4f*@>59Pm>|8D;0`M>1f zv?IIB&e-L4Z@aHO$ZoQavd7vJ?3wn__9A<=-DRI^UuIunUuj=$f5^Vc{;d6k{XP5l z1-L+7;8Sp0!N`KZf{+4LL0&;=!Gr=wL2bc31z^sk5?L~)WO7MU$=niBvY_Pdl6y*) zmMklIpk!6a&XPw<_LMwPvcKf1l0zlWmONK-tmH(=`z1e?vZeh?wWW!r<4Rqni%VCO zK2W- - - - - HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges - - SnapshotAutomaticallyBeforeSignificantChanges - - - diff --git a/ExpressionsLoader.playground/timeline.xctimeline b/ExpressionsLoader.playground/timeline.xctimeline deleted file mode 100644 index bf468af..0000000 --- a/ExpressionsLoader.playground/timeline.xctimeline +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/Swifternalization.xcodeproj/project.pbxproj b/Swifternalization.xcodeproj/project.pbxproj index 7c35ba9..e95c72a 100644 --- a/Swifternalization.xcodeproj/project.pbxproj +++ b/Swifternalization.xcodeproj/project.pbxproj @@ -26,8 +26,6 @@ 6D5BA5F11B6517A6000D7E49 /* TranslationsLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB3CC731B5EBDA600A1220F /* TranslationsLoader.swift */; }; 6D5BA5F31B651809000D7E49 /* LengthVariation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB3CC6A1B5EBDA600A1220F /* LengthVariation.swift */; }; 6D5BA5FB1B65253B000D7E49 /* SharedExpressionsProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA5FA1B65253B000D7E49 /* SharedExpressionsProcessor.swift */; }; - 6D5BA6001B6526F0000D7E49 /* SharedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA5FF1B6526F0000D7E49 /* SharedExpression.swift */; }; - 6D5BA6011B65271A000D7E49 /* SharedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA5FF1B6526F0000D7E49 /* SharedExpression.swift */; }; 6D5BA6041B6537D5000D7E49 /* SharedExpressionsProcessorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA6031B6537D5000D7E49 /* SharedExpressionsProcessorTests.swift */; }; 6D5BA6051B653935000D7E49 /* SharedExpressionsProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA5FA1B65253B000D7E49 /* SharedExpressionsProcessor.swift */; }; 6D5BA6091B655F1D000D7E49 /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA6081B655F1D000D7E49 /* Expression.swift */; }; @@ -73,12 +71,14 @@ 6DBB6C521B401B8A002F39A3 /* Swifternalization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5004641B3EF92600A54B36 /* Swifternalization.swift */; }; 6DBB6C691B4040F0002F39A3 /* InternalPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C681B4040F0002F39A3 /* InternalPattern.swift */; }; 6DBB6C6A1B40412D002F39A3 /* InternalPattern.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C681B4040F0002F39A3 /* InternalPattern.swift */; }; - 6DBB6C8F1B40768A002F39A3 /* SharedBaseExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C8C1B40768A002F39A3 /* SharedBaseExpression.swift */; }; - 6DBB6C911B40768A002F39A3 /* SharedPolishExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C8E1B40768A002F39A3 /* SharedPolishExpression.swift */; }; - 6DBB6C921B40769F002F39A3 /* SharedBaseExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C8C1B40768A002F39A3 /* SharedBaseExpression.swift */; }; - 6DBB6C941B40769F002F39A3 /* SharedPolishExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C8E1B40768A002F39A3 /* SharedPolishExpression.swift */; }; 6DBB6C961B4076E8002F39A3 /* SharedBaseExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C951B4076E8002F39A3 /* SharedBaseExpressionTests.swift */; }; 6DBB6C981B4077FA002F39A3 /* SharedPolishExpressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBB6C971B4077FA002F39A3 /* SharedPolishExpressionTests.swift */; }; + 6DBFC48D1B6D23E500F52208 /* SharedBaseExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48A1B6D23E500F52208 /* SharedBaseExpression.swift */; }; + 6DBFC48E1B6D23E500F52208 /* SharedBaseExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48A1B6D23E500F52208 /* SharedBaseExpression.swift */; }; + 6DBFC48F1B6D23E500F52208 /* SharedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48B1B6D23E500F52208 /* SharedExpression.swift */; }; + 6DBFC4901B6D23E500F52208 /* SharedExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48B1B6D23E500F52208 /* SharedExpression.swift */; }; + 6DBFC4911B6D23E500F52208 /* SharedPolishExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48C1B6D23E500F52208 /* SharedPolishExpression.swift */; }; + 6DBFC4921B6D23E500F52208 /* SharedPolishExpression.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DBFC48C1B6D23E500F52208 /* SharedPolishExpression.swift */; }; 6DD3B93A1B5ED35200C79EAC /* base.json in Resources */ = {isa = PBXBuildFile; fileRef = 6DD3B9371B5ED35200C79EAC /* base.json */; }; 6DD3B93B1B5ED35200C79EAC /* expressions.json in Resources */ = {isa = PBXBuildFile; fileRef = 6DD3B9381B5ED35200C79EAC /* expressions.json */; }; 6DD3B93C1B5ED35200C79EAC /* pl.json in Resources */ = {isa = PBXBuildFile; fileRef = 6DD3B9391B5ED35200C79EAC /* pl.json */; }; @@ -114,7 +114,6 @@ 6D5004641B3EF92600A54B36 /* Swifternalization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swifternalization.swift; sourceTree = ""; }; 6D5BA5EF1B651796000D7E49 /* TranslationsLoaderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranslationsLoaderTests.swift; sourceTree = ""; }; 6D5BA5FA1B65253B000D7E49 /* SharedExpressionsProcessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedExpressionsProcessor.swift; sourceTree = ""; }; - 6D5BA5FF1B6526F0000D7E49 /* SharedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SharedExpression.swift; path = ../SharedExpression.swift; sourceTree = ""; }; 6D5BA6031B6537D5000D7E49 /* SharedExpressionsProcessorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedExpressionsProcessorTests.swift; sourceTree = ""; }; 6D5BA6081B655F1D000D7E49 /* Expression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Expression.swift; sourceTree = ""; }; 6D6282931B3F052B00E65FCD /* TranslatablePairTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranslatablePairTests.swift; sourceTree = ""; }; @@ -145,10 +144,11 @@ 6DB3CC731B5EBDA600A1220F /* TranslationsLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TranslationsLoader.swift; sourceTree = ""; }; 6DB3CC8F1B5EC29600A1220F /* ExpressionPatternType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExpressionPatternType.swift; sourceTree = ""; }; 6DBB6C681B4040F0002F39A3 /* InternalPattern.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InternalPattern.swift; sourceTree = ""; }; - 6DBB6C8C1B40768A002F39A3 /* SharedBaseExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedBaseExpression.swift; sourceTree = ""; }; - 6DBB6C8E1B40768A002F39A3 /* SharedPolishExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedPolishExpression.swift; sourceTree = ""; }; 6DBB6C951B4076E8002F39A3 /* SharedBaseExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedBaseExpressionTests.swift; sourceTree = ""; }; 6DBB6C971B4077FA002F39A3 /* SharedPolishExpressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedPolishExpressionTests.swift; sourceTree = ""; }; + 6DBFC48A1B6D23E500F52208 /* SharedBaseExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SharedBaseExpression.swift; path = Swifternalization/SharedBaseExpression.swift; sourceTree = SOURCE_ROOT; }; + 6DBFC48B1B6D23E500F52208 /* SharedExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SharedExpression.swift; path = Swifternalization/SharedExpression.swift; sourceTree = SOURCE_ROOT; }; + 6DBFC48C1B6D23E500F52208 /* SharedPolishExpression.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SharedPolishExpression.swift; path = Swifternalization/SharedPolishExpression.swift; sourceTree = SOURCE_ROOT; }; 6DD3B9371B5ED35200C79EAC /* base.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = base.json; sourceTree = ""; }; 6DD3B9381B5ED35200C79EAC /* expressions.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = expressions.json; sourceTree = ""; }; 6DD3B9391B5ED35200C79EAC /* pl.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pl.json; sourceTree = ""; }; @@ -286,9 +286,9 @@ 6DBB6C8B1B40767B002F39A3 /* Shared Expressions */ = { isa = PBXGroup; children = ( - 6D5BA5FF1B6526F0000D7E49 /* SharedExpression.swift */, - 6DBB6C8C1B40768A002F39A3 /* SharedBaseExpression.swift */, - 6DBB6C8E1B40768A002F39A3 /* SharedPolishExpression.swift */, + 6DBFC48A1B6D23E500F52208 /* SharedBaseExpression.swift */, + 6DBFC48B1B6D23E500F52208 /* SharedExpression.swift */, + 6DBFC48C1B6D23E500F52208 /* SharedPolishExpression.swift */, ); path = "Shared Expressions"; sourceTree = ""; @@ -436,21 +436,21 @@ 6D5004661B3EF92600A54B36 /* Swifternalization.swift in Sources */, 6D62829A1B3F17CA00E65FCD /* Regex.swift in Sources */, 6D6282B51B3F3C4100E65FCD /* InequalitySign.swift in Sources */, - 6DBB6C8F1B40768A002F39A3 /* SharedBaseExpression.swift in Sources */, 6D4C4EBD1B6ABE0700B7839A /* Translation.swift in Sources */, 6DB3CC901B5EC29600A1220F /* ExpressionPatternType.swift in Sources */, 6DB3CC7A1B5EBDA600A1220F /* LengthVariation.swift in Sources */, 6DB3CC751B5EBDA600A1220F /* CountryCode.swift in Sources */, 6D4C4EB31B6AAE3200B7839A /* LoadedTranslationsProcessor.swift in Sources */, + 6DBFC48F1B6D23E500F52208 /* SharedExpression.swift in Sources */, 6D4C4EAF1B6AA48F00B7839A /* LoadedTranslation.swift in Sources */, - 6D5BA6001B6526F0000D7E49 /* SharedExpression.swift in Sources */, 6D62829F1B3F1FA000E65FCD /* InequalityExpressionParser.swift in Sources */, + 6DBFC48D1B6D23E500F52208 /* SharedBaseExpression.swift in Sources */, 6D6282A51B3F24A800E65FCD /* ExpressionParser.swift in Sources */, 6D4C4EB81B6AB6DE00B7839A /* LoadedTranslationType.swift in Sources */, 6DB3CC771B5EBDA600A1220F /* SharedExpressionLoader.swift in Sources */, 6DBB6C691B4040F0002F39A3 /* InternalPattern.swift in Sources */, + 6DBFC4911B6D23E500F52208 /* SharedPolishExpression.swift in Sources */, 6D5BA6091B655F1D000D7E49 /* Expression.swift in Sources */, - 6DBB6C911B40768A002F39A3 /* SharedPolishExpression.swift in Sources */, 6D6282C51B3F4ED100E65FCD /* RegexExpressionParser.swift in Sources */, 6D6282C71B3F4F2100E65FCD /* RegexExpressionMatcher.swift in Sources */, 6DB3CC791B5EBDA600A1220F /* JSONFileLoader.swift in Sources */, @@ -471,6 +471,7 @@ 6D6282C11B3F43C600E65FCD /* InequalityExtendedExpressionMatcherTests.swift in Sources */, 6DD3B9451B5ED58A00C79EAC /* SharedExpressionLoader.swift in Sources */, 6D75E6D41B6B6CFE00B370DC /* LoadedTranslationsProcessorTests.swift in Sources */, + 6DBFC4921B6D23E500F52208 /* SharedPolishExpression.swift in Sources */, 6D50045B1B3EF91600A54B36 /* SwifternalizationTests.swift in Sources */, 6D6282A61B3F25B900E65FCD /* InequalityExpressionParser.swift in Sources */, 6D6282B81B3F3E2200E65FCD /* InequalitySign.swift in Sources */, @@ -479,9 +480,9 @@ 6D5BA6051B653935000D7E49 /* SharedExpressionsProcessor.swift in Sources */, 6D6282A71B3F25BE00E65FCD /* ExpressionMatcher.swift in Sources */, 6DD3B94B1B5ED65A00C79EAC /* NSBundle+TestExtension.swift in Sources */, + 6DBFC4901B6D23E500F52208 /* SharedExpression.swift in Sources */, 6D6282C81B3F4F6400E65FCD /* RegexExpressionMatcher.swift in Sources */, 6DD3B9421B5ED3F000C79EAC /* JSONFileLoader.swift in Sources */, - 6D5BA6011B65271A000D7E49 /* SharedExpression.swift in Sources */, 6D4C4EC51B6AD01300B7839A /* LoadedTranslationsProcessor.swift in Sources */, 6DBB6C6A1B40412D002F39A3 /* InternalPattern.swift in Sources */, 6D62F9FC1B6B808400596A7C /* ExpressionJSONs.swift in Sources */, @@ -490,16 +491,15 @@ 6D4C4EB01B6AA54800B7839A /* LoadedTranslation.swift in Sources */, 6DB3CC911B5EC29E00A1220F /* ExpressionPatternType.swift in Sources */, 6D6282941B3F052B00E65FCD /* TranslatablePairTests.swift in Sources */, - 6DBB6C941B40769F002F39A3 /* SharedPolishExpression.swift in Sources */, 6DBB6C521B401B8A002F39A3 /* Swifternalization.swift in Sources */, 6D5BA5F01B651796000D7E49 /* TranslationsLoaderTests.swift in Sources */, 6D4C4EC41B6ACF2C00B7839A /* Translation.swift in Sources */, 6D6282BF1B3F42CA00E65FCD /* InequalityExpressionMatcherTests.swift in Sources */, - 6DBB6C921B40769F002F39A3 /* SharedBaseExpression.swift in Sources */, 6D5BA6041B6537D5000D7E49 /* SharedExpressionsProcessorTests.swift in Sources */, 6D6282B31B3F3C2800E65FCD /* InequalityExtendedExpressionParser.swift in Sources */, 6D140F441B56D03D00359143 /* RandomNumbers.swift in Sources */, 6D6282AD1B3F327C00E65FCD /* InequalityExpressionMatcher.swift in Sources */, + 6DBFC48E1B6D23E500F52208 /* SharedBaseExpression.swift in Sources */, 6D4C4EC61B6AD01D00B7839A /* Expression.swift in Sources */, 6D62829D1B3F19CC00E65FCD /* RegexTests.swift in Sources */, 6D6282CB1B3F508C00E65FCD /* RegexExpressionParserTests.swift in Sources */, diff --git a/Swifternalization/Shared Expressions/SharedBaseExpression.swift b/Swifternalization/SharedBaseExpression.swift similarity index 100% rename from Swifternalization/Shared Expressions/SharedBaseExpression.swift rename to Swifternalization/SharedBaseExpression.swift diff --git a/Swifternalization/Shared Expressions/SharedPolishExpression.swift b/Swifternalization/SharedPolishExpression.swift similarity index 100% rename from Swifternalization/Shared Expressions/SharedPolishExpression.swift rename to Swifternalization/SharedPolishExpression.swift From b77ad6d9118f88e514042a192511bb3b41cbd6b6 Mon Sep 17 00:00:00 2001 From: Tomasz Szulc Date: Sun, 15 Nov 2015 10:29:47 +0100 Subject: [PATCH 3/4] Update Swifternalization to work with newest Swift and Xcode 7.1 --- Swifternalization.xcodeproj/project.pbxproj | 9 ++++++--- .../xcschemes/Swifternalization.xcscheme | 13 ++++++++----- .../xcschemes/SwifternalizationTests.xcscheme | 13 ++++++++----- Swifternalization/Info.plist | 2 +- Swifternalization/Regex.swift | 10 +++++----- Swifternalization/TranslationsLoader.swift | 2 +- SwifternalizationTests/Info.plist | 2 +- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Swifternalization.xcodeproj/project.pbxproj b/Swifternalization.xcodeproj/project.pbxproj index 5aa61d2..70b4b4b 100644 --- a/Swifternalization.xcodeproj/project.pbxproj +++ b/Swifternalization.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ 6D5004541B3EF91600A54B36 /* Swifternalization.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D5004481B3EF91600A54B36 /* Swifternalization.framework */; }; 6D50045B1B3EF91600A54B36 /* SwifternalizationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D50045A1B3EF91600A54B36 /* SwifternalizationTests.swift */; }; 6D5004661B3EF92600A54B36 /* Swifternalization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5004641B3EF92600A54B36 /* Swifternalization.swift */; }; - 6D5004961B3EFFC100A54B36 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6D5004591B3EF91600A54B36 /* Info.plist */; }; 6D5BA5F01B651796000D7E49 /* TranslationsLoaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5BA5EF1B651796000D7E49 /* TranslationsLoaderTests.swift */; }; 6D5BA5F11B6517A6000D7E49 /* TranslationsLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB3CC731B5EBDA600A1220F /* TranslationsLoader.swift */; }; 6D5BA5F31B651809000D7E49 /* LengthVariation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DB3CC6A1B5EBDA600A1220F /* LengthVariation.swift */; }; @@ -384,7 +383,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = "Tomasz Szulc"; TargetAttributes = { 6D5004471B3EF91600A54B36 = { @@ -429,7 +428,6 @@ files = ( 6DD3B93B1B5ED35200C79EAC /* expressions.json in Resources */, 6DD3B93A1B5ED35200C79EAC /* base.json in Resources */, - 6D5004961B3EFFC100A54B36 /* Info.plist in Resources */, 6DD3B93C1B5ED35200C79EAC /* pl.json in Resources */, 6D43BA1D1B8BBA270072DEA6 /* ru.json in Resources */, ); @@ -562,6 +560,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -643,6 +642,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -663,6 +663,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; @@ -681,6 +682,7 @@ ); INFOPLIST_FILE = SwifternalizationTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -694,6 +696,7 @@ ); INFOPLIST_FILE = SwifternalizationTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/Swifternalization.xcodeproj/xcshareddata/xcschemes/Swifternalization.xcscheme b/Swifternalization.xcodeproj/xcshareddata/xcschemes/Swifternalization.xcscheme index 6682de5..72cfae2 100644 --- a/Swifternalization.xcodeproj/xcshareddata/xcschemes/Swifternalization.xcscheme +++ b/Swifternalization.xcodeproj/xcshareddata/xcschemes/Swifternalization.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:Swifternalization.xcodeproj"> + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -48,15 +48,18 @@ ReferencedContainer = "container:Swifternalization.xcodeproj"> + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Swifternalization/Regex.swift b/Swifternalization/Regex.swift index b0857bb..dd89bac 100644 --- a/Swifternalization/Regex.swift +++ b/Swifternalization/Regex.swift @@ -23,7 +23,7 @@ final class Regex { class func matchInString(str: String, pattern: String, capturingGroupIdx: Int?) -> String? { var resultString: String? - let range = NSMakeRange(0, distance(str.startIndex, str.endIndex)) + let range = NSMakeRange(0, str.startIndex.distanceTo(str.endIndex)) regexp(pattern)?.enumerateMatchesInString(str, options: NSMatchingOptions.ReportCompletion, range: range, usingBlock: { result, flags, stop in if let result = result { if let capturingGroupIdx = capturingGroupIdx where result.numberOfRanges > capturingGroupIdx { @@ -46,7 +46,7 @@ final class Regex { :returns: `String` that matches pattern or nil. */ class func firstMatchInString(str: String, pattern: String) -> String? { - if let result = regexp(pattern)?.firstMatchInString(str, options: .ReportCompletion, range: NSMakeRange(0, distance(str.startIndex, str.endIndex))) { + if let result = regexp(pattern)?.firstMatchInString(str, options: .ReportCompletion, range: NSMakeRange(0, str.startIndex.distanceTo(str.endIndex))) { return substring(str, range: result.range) } return nil @@ -61,7 +61,7 @@ final class Regex { */ class func matchesInString(str: String, pattern: String) -> [String] { var matches = [String]() - if let results = regexp(pattern)?.matchesInString(str, options: .ReportCompletion, range: NSMakeRange(0, distance(str.startIndex, str.endIndex))) { + if let results = regexp(pattern)?.matchesInString(str, options: .ReportCompletion, range: NSMakeRange(0, str.startIndex.distanceTo(str.endIndex))) { for result in results { matches.append(substring(str, range: result.range)) } @@ -93,8 +93,8 @@ final class Regex { :returns: A string contained in `range`. */ private class func substring(str: String, range: NSRange) -> String { - let startRange = advance(str.startIndex, range.location) - let endRange = advance(startRange, range.length) + let startRange = str.startIndex.advancedBy(range.location) + let endRange = startRange.advancedBy(range.length) return str.substringWithRange(Range(start: startRange, end: endRange)) } diff --git a/Swifternalization/TranslationsLoader.swift b/Swifternalization/TranslationsLoader.swift index 20b3ec3..e73721c 100644 --- a/Swifternalization/TranslationsLoader.swift +++ b/Swifternalization/TranslationsLoader.swift @@ -57,7 +57,7 @@ final class TranslationsLoader { */ if strings > 0 && dicts == 0 { let key = element.keys.first! - let toIndex = advance(key.startIndex, 1) + let toIndex = key.startIndex.advancedBy(1) return key.substringToIndex(toIndex) == "@" ? .WithLengthVariations : .WithExpressions } else if strings >= 0 && dicts > 0 { return .WithExpressionsAndLengthVariations diff --git a/SwifternalizationTests/Info.plist b/SwifternalizationTests/Info.plist index 90c39ea..8a04c4d 100644 --- a/SwifternalizationTests/Info.plist +++ b/SwifternalizationTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.tomaszszulc.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From 19a6f0c670543388027b5b185f933b55747986b5 Mon Sep 17 00:00:00 2001 From: Tomasz Szulc Date: Sun, 15 Nov 2015 10:30:01 +0100 Subject: [PATCH 4/4] Remove Swift 2 section from README --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 2804784..cd58dcd 100644 --- a/README.md +++ b/README.md @@ -488,9 +488,6 @@ Swifternalization is open sourced so everyone may contribute if want to. If you There is no guide for contributors but if you added new functionality you must write unit tests for it. -## Swift 2 -Swifternalization supports Swift 2 and works on Xcode 7 beta 4. Please check out *swift2* branch. - ## Things to do in future releases - Add more built-in expressions for another countries. - Add support for float numbers in built in expressions that uses regular expressions.