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()