i18n
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Joakim Svensson 2025-07-18 10:27:16 +00:00
parent 7f8f5a2da3
commit be693528a7
3 changed files with 24 additions and 58 deletions

15
.pages Normal file
View File

@ -0,0 +1,15 @@
title: SA6ANW
nav:
- Start: index.md
- HF: hf.md
- VHF/UHF DMR: vhfuhfdmr.md
- Satellite: satellite.md
- Portabel: portable.md
- AREDN: aredn.md
- MESHTASTIC: meshtastic.md
- Midsomer Murders: midsomer.md
- Services:
- Home Lab: homelab.md
- Caddy: caddy.md
- sa6anw.se: sa6anwse.md
- Smokeping: smokeping.md

View File

@ -1,43 +1,4 @@
import os
import re
import shutil
import yaml
SOURCE_DIR = "docs"
ENGLISH_DIR = "docs/en"
MKDOCS_YML = "mkdocs.yml"
# Kopiera alla filer från docs/ till docs_en/
if os.path.exists(ENGLISH_DIR):
shutil.rmtree(ENGLISH_DIR)
shutil.copytree(SOURCE_DIR, ENGLISH_DIR)
def clean_file(path, keep_lang):
with open(path, "r", encoding="utf-8") as f:
content = f.read()
if keep_lang == "sv":
content = re.sub(r":::\s*en\n.*?\n:::", "", content, flags=re.DOTALL)
elif keep_lang == "en":
content = re.sub(r":::\s*sv\n.*?\n:::", "", content, flags=re.DOTALL)
content = re.sub(r":::\s*(sv|en)", "", content)
content = re.sub(r":::", "", content)
with open(path, "w", encoding="utf-8") as f:
f.write(content.strip() + "\n")
# Rensa svenska versioner
for filename in os.listdir(SOURCE_DIR):
if filename.endswith(".md"):
clean_file(os.path.join(SOURCE_DIR, filename), keep_lang="sv")
# Rensa engelska versioner
for filename in os.listdir(ENGLISH_DIR):
if filename.endswith(".md"):
clean_file(os.path.join(ENGLISH_DIR, filename), keep_lang="en")
# Skapa .pages i docs/en/ baserat på nav i mkdocs.yml
# Skapa .pages i docs/ och docs/en/ baserat på nav i mkdocs.yml
def extract_nav_from_mkdocs_yml(path):
with open(path, "r", encoding="utf-8") as f:
data = yaml.safe_load(f)
@ -46,8 +7,13 @@ def extract_nav_from_mkdocs_yml(path):
"nav": data.get("nav", [])
}
english_pages = extract_nav_from_mkdocs_yml(MKDOCS_YML)
# Hämta navigation från mkdocs.yml
pages = extract_nav_from_mkdocs_yml(MKDOCS_YML)
os.makedirs(os.path.join(ENGLISH_DIR), exist_ok=True)
# Skriv till svenska .pages
with open(os.path.join(SOURCE_DIR, ".pages"), "w", encoding="utf-8") as f:
yaml.dump(pages, f, allow_unicode=True)
# Skriv till engelska .pages
with open(os.path.join(ENGLISH_DIR, ".pages"), "w", encoding="utf-8") as f:
yaml.dump(english_pages, f, allow_unicode=True)
yaml.dump(pages, f, allow_unicode=True)

View File

@ -1,19 +1,4 @@
site_name: SA6ANW
nav:
- Start: index.md
- HF: hf.md
- VHF/UHF DMR: vhfuhfdmr.md
- Satellite: satellite.md
- Portabel: portable.md
- AREDN: aredn.md
- MESHTASTIC: meshtastic.md
- Midsomer Murders: midsomer.md
- Services:
- Home Lab: homelab.md
- Caddy: caddy.md
- sa6anw.se: sa6anwse.md
- Smokeping: smokeping.md
theme:
name: 'material'
language: sv