| |
@@ -1,11 +1,12 @@
|
| |
#!/usr/bin/python3
|
| |
|
| |
- import tempfile, yaml, os, errno, subprocess, copy, datetime, shutil, sys
|
| |
+ import tempfile, yaml, os, errno, glob, subprocess, copy, datetime, shutil, sys
|
| |
|
| |
GLOBAL_CONFIG = {
|
| |
"docs_repo_url": "https://pagure.io/fedora-docs/docs-fp-o.git",
|
| |
"docs_repo_branch": "stg",
|
| |
- "translated_sources_repo_url": "https://pagure.io/fedora-docs/translated-sources.git"
|
| |
+ "translated_sources_repo_url": "https://pagure.io/fedora-docs/translated-sources.git",
|
| |
+ "translated_adockeywords_repo_url": "https://pagure.io/fedora-docs-l10n/asciidoc-keywords.git"
|
| |
}
|
| |
|
| |
|
| |
@@ -190,6 +191,32 @@
|
| |
subprocess.run(["git", "config", "user.email", "you@example.com"], cwd=path)
|
| |
subprocess.run(["git", "commit", "--allow-empty", "-m", "init"], cwd=path)
|
| |
|
| |
+ def prepare_localized_admonitions(languages):
|
| |
+ """ Asciidoc use keywords for admonitions and others items """
|
| |
+ config = GLOBAL_CONFIG
|
| |
+
|
| |
+ keywords = {}
|
| |
+
|
| |
+ with tempfile.TemporaryDirectory() as workdir:
|
| |
+ subprocess.run(["git", "clone", config["translated_adockeywords_repo_url"]], cwd=workdir)
|
| |
+
|
| |
+ translated_keywords_repo = os.path.join(workdir, "asciidoc-keywords")
|
| |
+
|
| |
+ languages = []
|
| |
+ print(translated_keywords_repo + "/langs/*/asciidoc-attributes.yml")
|
| |
+ for filename in glob.glob(translated_keywords_repo + "/langs/*/asciidoc-attributes.yml"):
|
| |
+ languages.append(filename.rsplit("/")[::-1][1])
|
| |
+
|
| |
+ for lang in languages:
|
| |
+ file = translated_keywords_repo + "/langs/" + lang + "/asciidoc-attributes.yml"
|
| |
+ with open(file, 'r') as stream:
|
| |
+ try:
|
| |
+ keywords[lang] = yaml.load(stream)
|
| |
+ except yaml.YAMLError as exc:
|
| |
+ print(exc)
|
| |
+
|
| |
+ return keywords
|
| |
+
|
| |
|
| |
def main():
|
| |
config = GLOBAL_CONFIG
|
| |
@@ -275,6 +302,10 @@
|
| |
|
| |
|
| |
log("")
|
| |
+ log("===== Preparing the translated ascidoc keywords =====")
|
| |
+ keywords = prepare_localized_admonitions(languages)
|
| |
+
|
| |
+ log("")
|
| |
log("===== Generating site.lang.yml files =====")
|
| |
for lang in languages:
|
| |
lang_site_yml = copy.deepcopy(original_site_yml)
|
| |
@@ -287,6 +318,12 @@
|
| |
lang_site_yml["content"]["branches"] = "HEAD"
|
| |
lang_site_yml["content"]["sources"] = []
|
| |
|
| |
+ if lang in keywords:
|
| |
+ if "attributes" in lang_site_yml["asciidoc"]:
|
| |
+ lang_site_yml["asciidoc"]["attributes"].append(keywords[lang])
|
| |
+ else:
|
| |
+ lang_site_yml["asciidoc"]["attributes"] = keywords[lang]
|
| |
+
|
| |
for component, versions in components.items():
|
| |
for version in versions:
|
| |
source = {}
|
| |
@@ -306,6 +343,9 @@
|
| |
for lang in languages:
|
| |
log("")
|
| |
log("===== Building the {lang} site =====".format(lang=lang))
|
| |
+ if lang is not "uk":
|
| |
+ continue
|
| |
+
|
| |
filename = "site-{lang}.yml".format(lang=lang)
|
| |
antora_env["ANTORA_LANGUAGE"] = lang
|
| |
result = subprocess.run(["antora", "--html-url-extension-style=indexify", os.path.join(docs_repo, filename)], env=antora_env)
|
| |