     return nil
 }()
 
+fileprivate var countPrefixRegex: NSRegularExpression? = {
+    do {
+        return try NSRegularExpression(pattern: "(:?^[0-9]+)(?:=)", options: [])
+    } catch {
+        assertionFailure("countPrefixRegex failed to compile")
+    }
+    return nil
+}()
+
 extension String {
+    var fullRange: NSRange {
+        return NSRange(location: 0, length: (self as NSString).length)
+    }
     var escapedString: String {
         return self.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\"").replacingOccurrences(of: "\n", with: "\\n")
     }
-    var pluralDictionary: NSDictionary? {
+    func pluralDictionary(with keys: [String]) -> NSDictionary? {
+		//https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/StringsdictFileFormat/StringsdictFileFormat.html#//apple_ref/doc/uid/10000171i-CH16-SW1
         guard let dictionaryRegex = dictionaryRegex else {
             return nil
         }
-        let fullRange = NSRange(location: 0, length: self.characters.count)
+        let fullRange = self.fullRange
         let mutableDictionary = NSMutableDictionary(capacity: 5)
         let results = dictionaryRegex.matches(in: self, options: [], range: fullRange)
         

        }
        
        let firstComponent = components[0]
        let other = components[countOfComponents - 1]
        guard firstComponent.hasPrefix("PLURAL:") else {
            return nil
        }
        
        let token = firstComponent.substring(from: firstComponent.index(firstComponent.startIndex, offsetBy: 7))
        guard token.characters.count == 2 else {
            return nil
        }
        
        let lower = index(startIndex, offsetBy: result.range.location)
        let upper = index(lower, offsetBy: result.range.length)
        let range = lower..<upper

let fm = FileManager.default

do {
	let keysByLanguage = ["pl": ["one", "few"], "sr": ["one", "few", "many"]]
	let defaultKeys = ["one"]
   let contents = try fm.contentsOfDirectory(atPath: "Wikipedia/Localizations")
   for filename in contents {
       print("parsing \(filename)")
       guard let locale = filename.components(separatedBy: ".").first?.lowercased(), locale != "base", locale != "qqq" else {
           continue
       }
       guard let twnStrings = NSDictionary(contentsOfFile: "Wikipedia/Localizations/\(locale).lproj/Localizable.strings") else {
