from importlib import resources
import json

def load_custom_rules():
    with resources.files("smart_translate.rules").joinpath("custom_rules.json").open("r") as f:
        return json.load(f)


def apply_custom_rules(text, rules=CUSTOM_REPLACEMENTS):
    for src, tgt in rules.items():
        text = text.replace(src, tgt)
    return text
