43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import json
|
|
import re
|
|
import os
|
|
|
|
def parse_dart_map(filepath):
|
|
translations = {}
|
|
if not os.path.exists(filepath):
|
|
return translations
|
|
with open(filepath, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
pattern = re.compile(r'^\s*([\'"])(.*?)\1\s*:\s*([\'"])(.*?)\3\s*,?\s*$', re.MULTILINE)
|
|
matches = pattern.findall(content)
|
|
for match in matches:
|
|
key = match[1]
|
|
val = match[3]
|
|
key = key.replace('\\"', '"').replace("\\'", "'")
|
|
val = val.replace('\\"', '"').replace("\\'", "'")
|
|
translations[key] = val
|
|
|
|
return translations
|
|
|
|
ar_eg = parse_dart_map("siro_driver/lib/controller/local/ar_eg.dart")
|
|
ar_jo = parse_dart_map("siro_driver/lib/controller/local/ar_jo.dart")
|
|
ar_sy = parse_dart_map("siro_driver/lib/controller/local/ar_sy.dart")
|
|
|
|
with open("siro_driver_translations_data.json", "r", encoding="utf-8") as f:
|
|
json_data = json.load(f)
|
|
|
|
missing_keys_list = json_data.get('missing_keys', [])
|
|
|
|
ar_sy_keys = set(ar_sy.keys())
|
|
ar_jo_keys = set(ar_jo.keys())
|
|
ar_eg_keys = set(ar_eg.keys())
|
|
missing_keys_set = set(missing_keys_list)
|
|
|
|
all_keys = ar_sy_keys.union(ar_jo_keys).union(ar_eg_keys).union(missing_keys_set)
|
|
print(f"Total unique keys in union: {len(all_keys)}")
|
|
|
|
print(f"Keys in ar_eg not in ar_sy: {ar_eg_keys - ar_sy_keys}")
|
|
print(f"Keys in ar_sy not in ar_jo: {ar_sy_keys - ar_jo_keys}")
|
|
print(f"Keys in ar_jo not in ar_sy: {ar_jo_keys - ar_sy_keys}")
|