Skip to content

Commit

Permalink
conf: Fix handling of composite language codes with regional specifier
Browse files Browse the repository at this point in the history
And fix another bug where I used `en` instead of a string.
  • Loading branch information
akien-mga committed Apr 27, 2020
1 parent e6b00ca commit 66d185d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
tags.add(tag.strip()) # noqa: F821

# Language / i18n

supported_languages = {
"en": "Godot Engine (%s) documentation in English",
"de": "Godot Engine (%s) Dokumentation auf Deutsch",
Expand All @@ -59,19 +60,31 @@
"ja": "Godot Engine (%s)の日本語のドキュメント",
"ko": "Godot Engine (%s) 문서 (한국어)",
"pl": "Dokumentacja Godot Engine (%s) w języku polskim",
"pt-br": "Documentação da Godot Engine (%s) em Português Brasileiro",
"pt_BR": "Documentação da Godot Engine (%s) em Português Brasileiro",
"ru": "Документация Godot Engine (%s) на русском языке",
"uk": "Документація до Godot Engine (%s) українською мовою",
"zh-cn": "Godot Engine (%s) 简体中文文档",
"zh_CN": "Godot Engine (%s) 简体中文文档",
}

# Some language codes used on Weblate/RTD and in the docs URL differ,
# so we need to remap them.
languages_remap = {
"pt_BR": "pt-br",
"zh_CN": "zh-cn",
}
languages_url = sorted(
[l for l in supported_languages.keys() if l not in languages_remap.keys()]
+ list(languages_remap.values())
)

language = os.getenv("READTHEDOCS_LANGUAGE", "en")
if not language in supported_languages.keys():
print("Unknown language: " + language)
print("Supported languages: " + ", ".join(supported_languages.keys()))
print(
"The configured language is either wrong, or it should be added to supported_languages in conf.py. Falling back to 'en'."
)
language = en
language = "en"

is_i18n = tags.has("i18n") # noqa: F821

Expand Down Expand Up @@ -120,7 +133,7 @@
"github_version": "master", # Version
"conf_py_path": "/", # Path in the checkout to the docs root
"godot_inject_language_links": True,
"godot_docs_supported_languages": list(supported_languages.keys()),
"godot_docs_supported_languages": languages_url,
"godot_docs_basepath": "https://docs.godotengine.org/",
"godot_docs_suffix": ".html",
"godot_default_lang": "en",
Expand Down

0 comments on commit 66d185d

Please sign in to comment.