Skip to content

Commit

Permalink
Fix locale names AGAIN :)
Browse files Browse the repository at this point in the history
this time formatting to ISO 639-1 dynamically
  • Loading branch information
mhilbrunner committed Apr 27, 2020
1 parent cc17b4c commit 3c79f3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 3 additions & 1 deletion _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
{% block linktags -%}
{% if godot_inject_language_links -%}
{% for alternate_lang in godot_docs_supported_languages -%}
<link rel="alternate" hreflang="{{ alternate_lang }}" href="{{ godot_docs_basepath }}{{ alternate_lang }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />
{# Convert to ISO 639-1 format, e.g. zh_CN -> zh-cn -#}
{% set alternate_lang_href = alternate_lang.lower().replace("_", "-") -%}
<link rel="alternate" hreflang="{{ alternate_lang_href }}" href="{{ godot_docs_basepath }}{{ alternate_lang }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />
{% endfor -%}
<link rel="alternate" hreflang="x-default" href="{{ godot_docs_basepath }}{{ godot_default_lang }}/{{ godot_canonical_version }}/{{ pagename }}{{ godot_docs_suffix }}" />

Expand Down
14 changes: 1 addition & 13 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@
"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)
Expand Down Expand Up @@ -109,7 +98,6 @@
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
on_rtd = os.environ.get("READTHEDOCS", None) == "True"


html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
if on_rtd:
Expand All @@ -133,7 +121,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": languages_url,
"godot_docs_supported_languages": list(supported_languages.keys()),
"godot_docs_basepath": "https://docs.godotengine.org/",
"godot_docs_suffix": ".html",
"godot_default_lang": "en",
Expand Down

0 comments on commit 3c79f3e

Please sign in to comment.