feat: refactor financial wallet UI components and add offline map service support

This commit is contained in:
Hamza-Ayed
2026-04-21 00:35:30 +03:00
parent 4293d20561
commit b92db3bb39
99 changed files with 22888 additions and 27387 deletions

41
scratch/extract_keys.py Normal file
View File

@@ -0,0 +1,41 @@
import os
import re
# Regex for .tr keys: matches 'string'.tr or "string".tr
tr_pattern = re.compile(r'[\'"]([^\'"]+)[\'"]\.tr')
# Regex for Text widgets or other common UI strings that might be hardcoded
# This is a bit broad, but helps find things like Text("Hello")
text_pattern = re.compile(r'Text\(\s*[\'"]([^\'"]+)[\'"]')
keys = set()
def scan_file(filepath):
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# Find all .tr usages
for match in tr_pattern.finditer(content):
keys.add(match.group(1))
# Find potential hardcoded strings in Text widgets
# (We only care about those NOT already using .tr)
# This is just for my manual review to see if I missed any
# for match in text_pattern.finditer(content):
# keys.add(match.group(1))
except Exception as e:
pass
def main():
root_dir = 'lib'
for root, dirs, files in os.walk(root_dir):
for file in files:
if file.endswith('.dart'):
scan_file(os.path.join(root, file))
# Print all found keys
for key in sorted(keys):
print(key)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,82 @@
import re
filepath = 'lib/controller/local/translations.dart'
with open(filepath, 'r', encoding='utf-8') as f:
lines = f.readlines()
new_lines = []
seen_keys_en = set()
seen_keys_ar = set()
in_en = False
in_ar = False
for line in lines:
if '"en": {' in line:
in_en = True
in_ar = False
new_lines.append(line)
continue
if '"ar": {' in line:
in_en = False
in_ar = True
new_lines.append(line)
continue
if '};' in line or ' }' in line:
if in_en or in_ar:
if ' }' in line:
in_en = False
in_ar = False
new_lines.append(line)
continue
# Try to extract key and value using a more careful approach
# Looking for: "key": "value",
# We find the first " and the last " and the middle separator ": "
stripped = line.strip()
if stripped.startswith('"') and (stripped.endswith('",') or stripped.endswith('"')):
# Split by ": " but only once
try:
# We need to find the ": " that separates key and value
# Since keys and values can contain ": ", we look for the one surrounded by quotes
# A common pattern is "...": "..."
parts = re.split(r'":\s+"', stripped)
if len(parts) >= 2:
# Key is from index 1 to second-to-last char of first part
key = parts[0][1:]
# Value is from index 0 to last char (excluding optional comma and final quote)
val_part = parts[1]
if val_part.endswith(','):
val = val_part[:-2]
comma = ','
else:
val = val_part[:-1]
comma = ''
# FIX 1: Trailing backslashes
if key.endswith('\\') and not key.endswith('\\\\'):
key += '\\'
if val.endswith('\\') and not val.endswith('\\\\'):
val += '\\'
# FIX 2: Unescaped dollar signs
key = re.sub(r'(?<!\\)\$', r'\$', key)
val = re.sub(r'(?<!\\)\$', r'\$', val)
# FIX 3: Deduplication
if in_en:
if key in seen_keys_en: continue
seen_keys_en.add(key)
if in_ar:
if key in seen_keys_ar: continue
seen_keys_ar.add(key)
new_lines.append(f' "{key}": "{val}"{comma}\n')
continue
except:
pass
new_lines.append(line)
with open(filepath, 'w', encoding='utf-8') as f:
f.writelines(new_lines)