Skip to content

Commit

Permalink
Fixed bug with empty single-line comment
Browse files Browse the repository at this point in the history
  • Loading branch information
NickP0is0n committed Jun 22, 2021
1 parent 6bb4aad commit abd142c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class LocalizeParser {
private String currentString = null;
private boolean multilineCommentMode = false;
private String currentMark = null;
private String header = null;

private final ArrayList<LocalizedString> strings = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ data class LocalizedString @JvmOverloads constructor(
} else {
val commentStrings = listOf(*comment.split("\n").toTypedArray())
commentStrings.forEach {
rawLocalizedStringBuilder
.append("//")
.append(it)
.append("\n")
if(it.isNotEmpty()) {
rawLocalizedStringBuilder
.append("//")
.append(it)
.append("\n")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ class LocalizeExporter {
val writer = PrintWriter(outputFile)
var lastMark: String? = null
var isFirstString = true
var isHeader = false

writer.use {
localizedStrings.forEach {
if (isFirstString && it.isCommentMultilined) {
writer.println("/*${it.comment}*/") // writing xcode copyright header on top
isHeader = true
}
if (it.mark != lastMark && it.mark != null) {
lastMark = it.mark
writer.println("\n// MARK:${it.mark}\n")
}
if (isFirstString) {
if (isFirstString && isHeader) {
writer.println(it.toStringWithoutComment())
isFirstString = false
}
Expand Down
6 changes: 2 additions & 4 deletions src/test/resources/exporter/withMultilineComment
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/*
Sample
comment
*/
/*Sample
comment*/
"CONTINUE-ERASE" = "Continue and Erase";

0 comments on commit abd142c

Please sign in to comment.