fix: Ignore non utf-8 files for translation scan (backport #12935) (#12936)

Co-authored-by: Faris Ansari <netchampfaris@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2021-04-21 12:18:11 +05:30 committed by GitHub
parent d296688b35
commit eae7f74d1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -518,8 +518,13 @@ def get_messages_from_file(path):
apps_path = get_bench_dir()
if os.path.exists(path):
with open(path, 'r') as sourcefile:
try:
file_contents = sourcefile.read()
except Exception:
print("Could not scan file for translation: {0}".format(path))
return []
data = [(os.path.relpath(path, apps_path), message, context, line) \
for line, message, context in extract_messages_from_code(sourcefile.read())]
for line, message, context in extract_messages_from_code(file_contents)]
return data
else:
# print "Translate: {0} missing".format(os.path.abspath(path))