i18n
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
d00dbf6ec8
commit
6ed58ac405
|
@ -4,10 +4,10 @@ import shutil
|
|||
import yaml
|
||||
|
||||
SOURCE_DIR = "docs"
|
||||
ENGLISH_DIR = "docs/en"
|
||||
ENGLISH_DIR = os.path.join(SOURCE_DIR, "en")
|
||||
MKDOCS_YML = "mkdocs.yml"
|
||||
|
||||
# Kopiera alla filer från docs/ till docs_en/
|
||||
# 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)
|
||||
|
@ -16,24 +16,48 @@ def clean_file(path, keep_lang):
|
|||
with open(path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# Ta bort block som inte ska vara kvar
|
||||
if keep_lang == "sv":
|
||||
content = re.sub(r":::\s*en\n.*?\n:::", "", content, flags=re.DOTALL)
|
||||
content = re.sub(r":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":sv\n.*?\n:::", "", content, flags=re.DOTALL)
|
||||
|
||||
content = re.sub(r":::\s*(sv|en)", "", content)
|
||||
content = re.sub(r":::", "", content)
|
||||
# Ta bort block-taggar för behållna block
|
||||
content = re.sub(r":(sv|en)\n", "", content)
|
||||
content = re.sub(r"\n:::", "", content)
|
||||
|
||||
# Hantera inline-taggar
|
||||
def inline_replacer(match):
|
||||
lang, text = match.groups()
|
||||
return text if lang == keep_lang else ""
|
||||
|
||||
content = re.sub(r"\[:(sv|en)](.*?)(?=(\[:|$))", inline_replacer, 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")
|
||||
full_path = os.path.join(SOURCE_DIR, filename)
|
||||
if filename.endswith(".md") and os.path.isfile(full_path):
|
||||
clean_file(full_path, 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")
|
||||
full_path = os.path.join(ENGLISH_DIR, filename)
|
||||
if filename.endswith(".md") and os.path.isfile(full_path):
|
||||
clean_file(full_path, keep_lang="en")
|
||||
|
||||
# Skapa .pages för engelska versionen utifrån mkdocs.yml
|
||||
def extract_nav_from_mkdocs_yml(path):
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = yaml.safe_load(f)
|
||||
return {
|
||||
"title": data.get("site_name", "SA6ANW"),
|
||||
"nav": data.get("nav", [])
|
||||
}
|
||||
|
||||
english_pages = extract_nav_from_mkdocs_yml(MKDOCS_YML)
|
||||
|
||||
with open(os.path.join(ENGLISH_DIR, ".pages"), "w", encoding="utf-8") as f:
|
||||
yaml.dump(english_pages, f, allow_unicode=True)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
title: Midsomer Murders
|
||||
---
|
||||
|
||||
::: sv
|
||||
:sv
|
||||
**Midsomer Murders – men var är amatörradion?**<br>
|
||||
|
||||
Midsomer Murders är en av de mest älskade brittiska kriminalserierna – inte bara tack vare sina snillrika mordgåtor, utan för hur varje avsnitt placerar oss i en ny, udda och charmig subkultur mitt i den lantliga idyllen. Vi har fått följa historier vid allt från new age-mässor, konstnärskollektiv och IQ-sällskap till rugbyklubbar, riddarföreningar och preppers – alltid med värme, humor och ett stänk brittisk excentricitet.
|
||||
|
@ -26,7 +26,7 @@ Låt radioamatörerna få sitt avsnitt!
|
|||
Oavsett om du är sändaramatör eller bara älskar serien – skriv gärna under och hjälp oss visa att detta är ett tema som många vill se!
|
||||
:::
|
||||
|
||||
::: en
|
||||
:en
|
||||
**Midsomer Murders – but where is amateur radio?**<br>
|
||||
|
||||
Midsomer Murders is one of Britain's most beloved detective series – not just for its clever plots, but for the way each episode dives into a new, quirky subculture nestled in the peaceful countryside. We've seen episodes set among new age fairs, art collectives, IQ societies, rugby clubs, medieval reenactors, doomsday preppers – always with warmth, charm, and a distinctly British wink.
|
||||
|
@ -95,7 +95,7 @@ Whether you're a licensed ham or just a loyal viewer, add your name and help us
|
|||
<input type="text" name="fornamn" required><br>
|
||||
<label>Efternamn / Surname:</label><br>
|
||||
<input type="text" name="efternamn" required><br><br>
|
||||
<input type="submit" value="Skicka / Send">
|
||||
<input type="submit" value="[:sv]Skicka[:][:en]Send[:]">
|
||||
</form>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue