Skip to content

Commit 6831115

Browse files
minuscorpsebastianvarela
authored andcommitted
Bump version
- Fixed a bug when finding scaped character secuences on a string.
1 parent 6a7d3f1 commit 6831115

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

POEditorParser.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "POEditorParser"
4-
s.version = "0.3.5"
4+
s.version = "0.3.6"
55
s.summary = "`POEditorParser` generates a swift file with an input strings file from POEditor."
66

77
s.description = <<-DESC

Sources/POEditorParser/Lib/LiteralsParser.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,14 @@ public class StringTranslationParser: TranslationParser {
274274
s.scanLocation += 1
275275

276276
var value: NSString?
277-
s.scanUpTo("\"", into: &value)
278-
s.scanLocation += 1
277+
s.scanUpTo("\";", into: &value)
278+
s.scanLocation += 2
279+
var finalValue: NSString?
280+
if let value = value {
281+
finalValue = value.substring(to: value.length - 1).unescaped as NSString
282+
}
279283

280-
translations.append(Translation(rawKey: key! as String, rawValue: value as String? ?? ""))
284+
translations.append(Translation(rawKey: key! as String, rawValue: finalValue as String? ?? ""))
281285

282286
}
283287
if s.isAtEnd {

Sources/POEditorParser/Lib/Swift+Extensions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@ extension String {
1313
let range = NSMakeRange(0, self.count)
1414
return regex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: replacing)
1515
}
16+
17+
var unescaped: String {
18+
let entities = ["\0", "\t", "\n", "\r", "\"", "\'", "\\"]
19+
var current = self
20+
for entity in entities {
21+
let descriptionCharacters = entity.debugDescription.dropFirst().dropLast()
22+
current = current.replacingOccurrences(of: descriptionCharacters, with: entity)
23+
}
24+
return current
25+
}
1626
}

bin/poe

324 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)