import yaml import os with open("content.yaml", "r") as f: content = yaml.safe_load(f) for page_name, translations in content.items(): template_file = f"template-{page_name}.html" with open(template_file, "r") as f: template = f.read() for lang, page_data in translations.items(): output = template output = output.replace("{{lang}}", lang) for key, value in page_data.items(): output = output.replace(f"{{{{{key}}}}}", value) output_dir = lang os.makedirs(output_dir, exist_ok=True) output_file = os.path.join(output_dir, f"{page_name}.html") with open(output_file, "w") as f: f.write(output) print(f"{output_file} generated.")