Skip to content

Commit 7cc961c

Browse files
committed
Update project to swift 5
Fixed the empty string issue
1 parent 18a4025 commit 7cc961c

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

POEditor.xcodeproj/project.pbxproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
developmentRegion = English;
242242
hasScannedForEncodings = 0;
243243
knownRegions = (
244+
English,
244245
en,
245246
);
246247
mainGroup = A790D68C1DCDF35F0060C52B;
@@ -365,6 +366,7 @@
365366
ONLY_ACTIVE_ARCH = YES;
366367
SDKROOT = macosx;
367368
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
369+
SWIFT_VERSION = 5.0;
368370
};
369371
name = Debug;
370372
};
@@ -415,6 +417,7 @@
415417
MTL_ENABLE_DEBUG_INFO = NO;
416418
SDKROOT = macosx;
417419
SWIFT_COMPILATION_MODE = wholemodule;
420+
SWIFT_VERSION = 5.0;
418421
};
419422
name = Release;
420423
};
@@ -425,7 +428,7 @@
425428
MACOSX_DEPLOYMENT_TARGET = 10.11;
426429
PRODUCT_NAME = poet;
427430
SWIFT_SWIFT3_OBJC_INFERENCE = On;
428-
SWIFT_VERSION = 4.2;
431+
SWIFT_VERSION = 5.0;
429432
};
430433
name = Debug;
431434
};
@@ -436,7 +439,7 @@
436439
MACOSX_DEPLOYMENT_TARGET = 10.11;
437440
PRODUCT_NAME = poet;
438441
SWIFT_SWIFT3_OBJC_INFERENCE = On;
439-
SWIFT_VERSION = 4.2;
442+
SWIFT_VERSION = 5.0;
440443
};
441444
name = Release;
442445
};
@@ -460,7 +463,7 @@
460463
PRODUCT_NAME = POEditorAPI;
461464
SKIP_INSTALL = YES;
462465
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
463-
SWIFT_VERSION = 3.0;
466+
SWIFT_VERSION = 5.0;
464467
VERSIONING_SYSTEM = "apple-generic";
465468
VERSION_INFO_PREFIX = "";
466469
};
@@ -486,7 +489,7 @@
486489
PRODUCT_NAME = POEditorAPI;
487490
SKIP_INSTALL = YES;
488491
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
489-
SWIFT_VERSION = 3.0;
492+
SWIFT_VERSION = 5.0;
490493
VERSIONING_SYSTEM = "apple-generic";
491494
VERSION_INFO_PREFIX = "";
492495
};
@@ -512,7 +515,7 @@
512515
SDKROOT = iphoneos;
513516
SKIP_INSTALL = YES;
514517
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
515-
SWIFT_VERSION = 3.0;
518+
SWIFT_VERSION = 5.0;
516519
TARGETED_DEVICE_FAMILY = "1,2";
517520
VERSIONING_SYSTEM = "apple-generic";
518521
VERSION_INFO_PREFIX = "";
@@ -539,7 +542,7 @@
539542
SDKROOT = iphoneos;
540543
SKIP_INSTALL = YES;
541544
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
542-
SWIFT_VERSION = 3.0;
545+
SWIFT_VERSION = 5.0;
543546
TARGETED_DEVICE_FAMILY = "1,2";
544547
VALIDATE_PRODUCT = YES;
545548
VERSIONING_SYSTEM = "apple-generic";

Tool/Source/Translation.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,31 @@ extension Collection where Iterator.Element == Translation
6767
switch transUnit.translated
6868
{
6969
case .hasDefinition(let translation):
70-
translatedTerm = translation
70+
translatedTerm = translation
7171

7272
case .hasPlurals(let plurals):
7373
translatedTerm = plurals["other"]
7474

7575
case .notTranslated:
7676
continue
7777
}
78-
79-
if !tmpStr.isEmpty
80-
{
78+
// escape double quotes to be safe
79+
let cleanTranslation = translatedTerm.replacingOccurrences(of: "\n", with: "\\n").replacingOccurrences(of: "\"", with: "\\\"")
80+
81+
if cleanTranslation.isEmpty {
82+
continue
83+
}
84+
85+
if !tmpStr.isEmpty {
8186
tmpStr += "\n"
8287
}
8388

84-
if let note = transUnit.comment, !note.isEmpty
85-
{
89+
if let note = transUnit.comment, !note.isEmpty {
8690
let noteWithLinebreaks = note.replacingOccurrences(of: "\\n", with: "\n", options: [], range: nil)
8791
tmpStr += "/* \(noteWithLinebreaks) */\n"
8892
}
89-
90-
// escape double quotes to be safe
91-
let cleanTranslation = translatedTerm.replacingOccurrences(of: "\n", with: "\\n").replacingOccurrences(of: "\"", with: "\\\"")
92-
93-
tmpStr += "\"\(transUnit.term)\" = \"\(cleanTranslation)\";\n"
93+
94+
tmpStr += "\"\(transUnit.term)\" = \"\(cleanTranslation)\";\n"
9495
}
9596

9697
let outputName = justName + ".strings"

0 commit comments

Comments
 (0)