diff --git a/build.py b/build.py index 4448118..6868a93 100644 --- a/build.py +++ b/build.py @@ -1,6 +1,11 @@ import yaml import os +LANG_LABELS = { + "en": "English", + "de": "Deutsch", +} + with open("content.yaml", "r") as f: content = yaml.safe_load(f) @@ -10,13 +15,28 @@ for page_name, translations in content.items(): with open(template_file, "r") as f: template = f.read() + languages = list(translations.keys()) + 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 = output.replace("{{lang}}", lang) + + links = [] + for other_lang in languages: + if other_lang == lang: + continue + + label = LANG_LABELS.get(other_lang, other_lang) + link = f'{label}' + links.append(link) + + language_switcher = " ".join(links) + output = output.replace("{{language-switcher}}", language_switcher) + output_dir = lang os.makedirs(output_dir, exist_ok=True) diff --git a/de/index.html b/de/index.html index ca18569..b00a0fb 100644 --- a/de/index.html +++ b/de/index.html @@ -12,9 +12,8 @@
und das ist meine Webseite
-