check-translation.py: Add option to force different src language

This commit is contained in:
MrS0m30n3 2017-09-27 17:06:07 +03:00
parent d12a075b78
commit c37c557ad2

View File

@ -48,6 +48,7 @@ def parse():
parser.add_argument("-w", "--werror", action="store_true", help="treat all warning messages as errors") parser.add_argument("-w", "--werror", action="store_true", help="treat all warning messages as errors")
parser.add_argument("-o", "--only-headers", action="store_true", help="check only the PO file headers") parser.add_argument("-o", "--only-headers", action="store_true", help="check only the PO file headers")
parser.add_argument("-n", "--no-translate", action="store_true", help="do not use the translator to check 'msgstr' fields") parser.add_argument("-n", "--no-translate", action="store_true", help="do not use the translator to check 'msgstr' fields")
parser.add_argument("-t", "--tlang", help="force a different language on the translator than the one given")
return parser.parse_args() return parser.parse_args()
@ -199,6 +200,11 @@ def main(args):
translator = google_translate.GoogleTranslator(timeout=5.0, retries=2, wait_time=WTIME) translator = google_translate.GoogleTranslator(timeout=5.0, retries=2, wait_time=WTIME)
# Set source language for GoogleTranslator
if args.tlang is not None:
src_lang = args.tlang
pinfo("Forcing '{}' as the translator's source language".format(src_lang))
else:
# Get a valid source language for Google # Get a valid source language for Google
# for example convert 'ar_SA' to 'ar' or 'zh_CN' to 'zh-CN' # for example convert 'ar_SA' to 'ar' or 'zh_CN' to 'zh-CN'
src_lang = args.language src_lang = args.language