l10n script: --lang takes a filename argument now

This allows for forcing unix-style line endings to the file, rather than
needing to mess with dos2unix after on a Windows system.
This commit is contained in:
Athanasius committed 2021-06-07 15:05:26 +01:00
1 parent 32101bdba5
commit 06725467f9
1 file changed
+7 -2
+7 -2
View File
@@ -273,7 +273,7 @@ if __name__ == '__main__':
parser.add_argument('--ignore', action='append', help='directories to ignore', default=['venv', '.git'])
group = parser.add_mutually_exclusive_group()
group.add_argument('--json', action='store_true', help='JSON output')
group.add_argument('--lang', action='store_true', help='en.template "strings" output')
group.add_argument('--lang', help='en.template "strings" output to specified file, "-" for stdout')
group.add_argument('--compare-lang', help='en.template file to compare against')
args = parser.parse_args()
@@ -313,7 +313,12 @@ if __name__ == '__main__':
print(json.dumps(to_print_data, indent=2))
elif args.lang:
print(generate_lang_template(res))
if args.lang == '-':
print(generate_lang_template(res))
else:
with open(args.lang, mode='w+', newline='\n') as langfile:
langfile.writelines(generate_lang_template(res))
else:
for path, calls in res.items():