Skip to content

Commit

Permalink
Fix i18n string parsing for non-ascii characters (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanspw authored Jul 23, 2023
1 parent 3c68b6e commit 3fada8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions find_missing_i18n_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

# Open the json file and load its contents into a dictionary
with open('i18n/en.json', 'r') as f:
with open('i18n/en.json', 'r', encoding='utf-8') as f:
en = json.load(f)

# Create a copy of the en dictionary's keys and convert it to a set for better performance
Expand All @@ -18,7 +18,7 @@
for file in files:
if file.endswith('.html'):
fullpath = os.path.join(folder, file)
with open(fullpath, 'r') as f:
with open(fullpath, 'r', encoding='utf-8') as f:
for line in f:
m = re.findall('{{\s+?i18n\s+?(?:"|`)(.*?)(?:"|`)\s+?}}', line, re.DOTALL)
if m:
Expand All @@ -42,5 +42,5 @@
else:
print("No unused keys found.")

with open('i18n/en.json', 'w') as f:
json.dump(en, f, indent=3)
with open('i18n/en.json', 'w', encoding='utf-8') as f:
json.dump(en, f, indent=3, ensure_ascii=False)

0 comments on commit 3fada8d

Please sign in to comment.