diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index 314f81140..804813df2 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -183,6 +183,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - css/termynal.css - css/custom.css diff --git a/docs/es/mkdocs.yml b/docs/es/mkdocs.yml index ae178487d..16a6301a8 100644 --- a/docs/es/mkdocs.yml +++ b/docs/es/mkdocs.yml @@ -87,6 +87,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/fr/mkdocs.yml b/docs/fr/mkdocs.yml index 5ce390c26..ad3aa6303 100644 --- a/docs/fr/mkdocs.yml +++ b/docs/fr/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/it/mkdocs.yml b/docs/it/mkdocs.yml index 11c4a2e4d..9a234987b 100644 --- a/docs/it/mkdocs.yml +++ b/docs/it/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/ja/mkdocs.yml b/docs/ja/mkdocs.yml index ea591d41d..c264230af 100644 --- a/docs/ja/mkdocs.yml +++ b/docs/ja/mkdocs.yml @@ -102,6 +102,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/ko/mkdocs.yml b/docs/ko/mkdocs.yml index f196175ce..6607887d0 100644 --- a/docs/ko/mkdocs.yml +++ b/docs/ko/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/pt/mkdocs.yml b/docs/pt/mkdocs.yml index b1e813ec5..acb50b95c 100644 --- a/docs/pt/mkdocs.yml +++ b/docs/pt/mkdocs.yml @@ -88,6 +88,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/ru/mkdocs.yml b/docs/ru/mkdocs.yml index 695363a5b..dae88dc07 100644 --- a/docs/ru/mkdocs.yml +++ b/docs/ru/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/sq/mkdocs.yml b/docs/sq/mkdocs.yml index 2bab20d24..f447c1339 100644 --- a/docs/sq/mkdocs.yml +++ b/docs/sq/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/tr/mkdocs.yml b/docs/tr/mkdocs.yml index a26b255d6..6579cda91 100644 --- a/docs/tr/mkdocs.yml +++ b/docs/tr/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/uk/mkdocs.yml b/docs/uk/mkdocs.yml index a4d095a93..bc19ac946 100644 --- a/docs/uk/mkdocs.yml +++ b/docs/uk/mkdocs.yml @@ -80,6 +80,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/docs/zh/mkdocs.yml b/docs/zh/mkdocs.yml index 99916e4c2..f02bc7d88 100644 --- a/docs/zh/mkdocs.yml +++ b/docs/zh/mkdocs.yml @@ -107,6 +107,31 @@ extra: link: https://medium.com/@tiangolo - icon: fontawesome/solid/globe link: https://tiangolo.com + alternate: + - link: / + name: en - English + - link: /es/ + name: es - español + - link: /fr/ + name: fr - français + - link: /it/ + name: it - italiano + - link: /ja/ + name: ja - 日本語 + - link: /ko/ + name: ko - 한국어 + - link: /pt/ + name: pt - português + - link: /ru/ + name: ru - русский язык + - link: /sq/ + name: sq - shqip + - link: /tr/ + name: tr - Türkçe + - link: /uk/ + name: uk - українська мова + - link: /zh/ + name: zh - 汉语 extra_css: - https://fastapi.tiangolo.com/css/termynal.css - https://fastapi.tiangolo.com/css/custom.css diff --git a/scripts/docs.py b/scripts/docs.py index b8d162f63..b206e9157 100644 --- a/scripts/docs.py +++ b/scripts/docs.py @@ -4,7 +4,7 @@ import shutil from http.server import HTTPServer, SimpleHTTPRequestHandler from multiprocessing import Pool from pathlib import Path -from typing import Dict, Optional, Tuple +from typing import Dict, List, Optional, Tuple import mkdocs.commands.build import mkdocs.commands.serve @@ -364,12 +364,24 @@ def update_config(lang: str): config["nav"] = current_config["nav"] config["theme"]["language"] = current_config["theme"]["language"] languages = [{"en": "/"}] - for lang in get_lang_paths(): - if lang.name == "en" or not lang.is_dir(): + alternate: List[Dict[str, str]] = config["extra"].get("alternate", []) + alternate_dict = {alt["link"]: alt["name"] for alt in alternate} + new_alternate: List[Dict[str, str]] = [] + for lang_path in get_lang_paths(): + if lang_path.name == "en" or not lang_path.is_dir(): continue - name = lang.name + name = lang_path.name languages.append({name: f"/{name}/"}) + for lang_dict in languages: + name = list(lang_dict.keys())[0] + url = lang_dict[name] + if url not in alternate_dict: + new_alternate.append({"link": url, "name": name}) + else: + use_name = alternate_dict[url] + new_alternate.append({"link": url, "name": use_name}) config["nav"][1] = {"Languages": languages} + config["extra"]["alternate"] = new_alternate config_path.write_text( yaml.dump(config, sort_keys=False, width=200, allow_unicode=True), encoding="utf-8",