38 lines
891 B
Python
38 lines
891 B
Python
|
|
import re
|
||
|
|
|
||
|
|
with open('src/contexts/LocaleContext.tsx', 'r', encoding='utf-8') as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
lines = content.split('\n')
|
||
|
|
seen_keys = {}
|
||
|
|
new_lines = []
|
||
|
|
in_zhcn = False
|
||
|
|
in_enus = False
|
||
|
|
|
||
|
|
for line in lines:
|
||
|
|
if 'const zhCN = {' in line:
|
||
|
|
in_zhcn = True
|
||
|
|
in_enus = False
|
||
|
|
seen_keys = {}
|
||
|
|
elif 'const enUS = {' in line:
|
||
|
|
in_enus = True
|
||
|
|
in_zhcn = False
|
||
|
|
seen_keys = {}
|
||
|
|
|
||
|
|
match = re.match(r"^\s*'([^']+)':\s*'[^']*'", line)
|
||
|
|
if match:
|
||
|
|
key = match.group(1)
|
||
|
|
if key in seen_keys:
|
||
|
|
print(f'Duplicate: {key}')
|
||
|
|
continue
|
||
|
|
else:
|
||
|
|
seen_keys[key] = True
|
||
|
|
|
||
|
|
new_lines.append(line)
|
||
|
|
|
||
|
|
new_content = '\n'.join(new_lines)
|
||
|
|
with open('src/contexts/LocaleContext.tsx', 'w', encoding='utf-8') as f:
|
||
|
|
f.write(new_content)
|
||
|
|
|
||
|
|
print(f'Fixed! Lines: {len(lines)} -> {len(new_lines)}')
|