From d094d994566591aa016bea2b3cb445207fc8244a Mon Sep 17 00:00:00 2001 From: metasmile Date: Thu, 30 Aug 2018 22:38:59 +0200 Subject: [PATCH] genl10n.py - exclude commented lines --- utils/genl10n.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/genl10n.py b/utils/genl10n.py index aa46ec8..4d59665 100644 --- a/utils/genl10n.py +++ b/utils/genl10n.py @@ -19,7 +19,7 @@ parser.add_argument('src_path', help='Main swift source path, default=./)', default='./', nargs='?') -parser.add_argument('dest_l10n_base_path', help='Target Base localization resource path. (root path of Base.lproj, default=./)', +parser.add_argument('dest_l10n_base_path', help='Target Base Localizable.strings path. (default=./)', default='./', nargs='?') parser.add_argument('-k', '--split-key', help='Splitting identifier to extract strings from Swift code. (e.g. "This is string".localized )', @@ -39,6 +39,8 @@ # for excluing format literal -> \(value) qs = re.compile(r'\\\((.+)\)', re.I|re.U) +# for excluing code comment +cs = re.compile(r'\/\/.*', re.I|re.U) swift_files = [] @@ -51,6 +53,10 @@ rcur = codecs.open(code_file, "r", "utf-8") wlines = [] for i, line in enumerate(rcur.readlines()): + + if cs.search(line): + line = cs.sub("", line) + for line_sp in line.split(split_key): for p in complied_patterns_by_priority: