feat: add config loader for keywords

This commit is contained in:
2026-05-03 12:55:17 -05:00
parent 89b4523895
commit b06bfe7727
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,38 @@
"""Load keyword mappings from JSON config."""
import json
from pathlib import Path
DEFAULT_KEYWORDS = {
"print": "இருப்பு",
"if": "இணை",
"else": "இல்லை",
"for": "ஒவ்வொரு",
"while": "வரை",
"def": "வரையறை",
"return": "திரும்ப",
"import": "மேற்கோள்கள்",
"from": "இருந்து",
"as": "இவ்வாறு",
"class": "சாம்பியன்",
"try": "கோட்பாடு",
"except": "வெளியே",
"with": "உடன்",
"True": "சரி",
"False": "தவறு",
"None": "ஒன்றுமில்லை",
}
def load_keywords(config_path: Path | str) -> dict[str, str]:
"""Load keywords from JSON file, merge with defaults."""
defaults = DEFAULT_KEYWORDS.copy()
path = Path(config_path) if isinstance(config_path, str) else config_path
if path.exists():
with open(path, "r", encoding="utf-8") as f:
user_keywords = json.load(f)
defaults.update(user_keywords)
return defaults