From 06725467f9c30bfcbf1eab5296832eafcae0b52d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 7 Jun 2021 15:05:26 +0100 Subject: [PATCH] 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. --- scripts/find_localised_strings.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/find_localised_strings.py b/scripts/find_localised_strings.py index 8d19bb68..c65e383e 100644 --- a/scripts/find_localised_strings.py +++ b/scripts/find_localised_strings.py @@ -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():