Browse Source

🌐 Add docs lang selector widget (#2542)

*  Add language selector widget

* 🔧 Update script to re-generate MkDocs configs, including langs widget

* 🔧 Update languages MkDocs configs, with lang selector widget
pull/2543/head
Sebastián Ramírez 4 years ago
committed by GitHub
parent
commit
9f89399f5e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      docs/en/mkdocs.yml
  2. 25
      docs/es/mkdocs.yml
  3. 25
      docs/fr/mkdocs.yml
  4. 25
      docs/it/mkdocs.yml
  5. 25
      docs/ja/mkdocs.yml
  6. 25
      docs/ko/mkdocs.yml
  7. 25
      docs/pt/mkdocs.yml
  8. 25
      docs/ru/mkdocs.yml
  9. 25
      docs/sq/mkdocs.yml
  10. 25
      docs/tr/mkdocs.yml
  11. 25
      docs/uk/mkdocs.yml
  12. 25
      docs/zh/mkdocs.yml
  13. 20
      scripts/docs.py

25
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

25
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

25
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

25
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

25
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

25
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

25
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

25
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

25
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

25
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

25
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

25
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

20
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",

Loading…
Cancel
Save