fix: Python 3 issue on re (#13230)

Python 3 interprets string literals as Unicode strings, and therefore \s and \g are treated as escaped Unicode characters.

Fix: Declare RegEx pattern as a raw string instead by prepending r
This commit is contained in:
Joseph Marie Alba 2021-05-21 15:44:33 +08:00 committed by GitHub
parent ad5778275d
commit e8d79030f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -650,7 +650,7 @@ def write_csv_file(path, app_messages, lang_dict):
t = lang_dict.get(message, '')
# strip whitespaces
translated_string = re.sub('{\s?([0-9]+)\s?}', "{\g<1>}", t)
translated_string = re.sub(r'{\s?([0-9]+)\s?}', r"{\g<1>}", t)
if translated_string:
w.writerow([message, translated_string, context])