From e2e1aeac715a38f82f9804997f5eeb89d4113973 Mon Sep 17 00:00:00 2001 From: Max Hilbrunner Date: Mon, 20 Apr 2020 22:18:48 +0200 Subject: [PATCH] Appease our great search engine overlords MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This hopefully fixes all translated pages showing up in search engine results, and makes the STABLE version of each page canonical. In turn, this allows us to re-enable indexing of the version-specific pages (see robots.txt changes), as search engines should prefer the canonical (stable) version, and only show the other versions if no canonical (stable) version exists (i.e. because that feature is only in latest, or was removed in stable). It adds proper canonical links for all generated pages, and fixes the existing links between the various translations of a page by both ensuring the pages links to itself with the proper language tag, and by properly linking to the full path of other translated versions. (cherry picked from commits: - fd5f6f49097ab916ff3f5daa433c6e57d0a59716, - 263ff562516c98fa6113c920ea7281e21d2d9f79, - e21df0671fe5a5aeb0e6253084dd842bad6114da, - 24781e377baad9375aaa7c7175e0bedb5c9c0414, - 66d185d5d2d51cfd8c28716930d1ca04ff51090b, - 3c79f3e3218bff53a6303e7b85ebe2089c09c4b6) Co-authored-by: Rémi Verschelde --- _templates/layout.html | 14 +++++++ .../contributing/documentation_guidelines.rst | 6 ++- conf.py | 38 +++++++++++++++++-- robots.txt | 4 -- 4 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 _templates/layout.html diff --git a/_templates/layout.html b/_templates/layout.html new file mode 100644 index 000000000..84503df34 --- /dev/null +++ b/_templates/layout.html @@ -0,0 +1,14 @@ +{% extends "!layout.html" -%} +{% block linktags -%} + {% if godot_inject_language_links -%} + {% for alternate_lang in godot_docs_supported_languages -%} + {# Convert to ISO 639-1 format, e.g. zh_CN -> zh-cn -#} + {% set alternate_lang_href = alternate_lang.lower().replace("_", "-") -%} + + {% endfor -%} + + + + {% endif -%} + {{ super() }} +{% endblock -%} diff --git a/community/contributing/documentation_guidelines.rst b/community/contributing/documentation_guidelines.rst index 781155bca..41ce00070 100644 --- a/community/contributing/documentation_guidelines.rst +++ b/community/contributing/documentation_guidelines.rst @@ -95,8 +95,12 @@ You can help to translate the official Godot documentation on our `Hosted Weblat :alt: Translation state :align: center :target: https://hosted.weblate.org/engage/godot-engine/?utm_source=widget + :width: 287 + :height: 66 -There also is the official `Godot I18N repository `_. where you can see when the data was last synced. +There also is the official +`Godot i18n repository `_ +where you can see when the data was last synchronized. License ------- diff --git a/conf.py b/conf.py index 714d782f4..721d9b33a 100644 --- a/conf.py +++ b/conf.py @@ -38,7 +38,32 @@ version = os.getenv("READTHEDOCS_VERSION", "3.0") # The full version, including alpha/beta/rc tags release = version -language = "en" +# Language / i18n + +supported_languages = { + "en": "Godot Engine (%s) documentation in English", + "de": "Godot Engine (%s) Dokumentation auf Deutsch", + "es": "Documentación de Godot Engine (%s) en español", + "fr": "Documentation de Godot Engine (%s) en français", + "fi": "Godot Engine (%s) dokumentaatio suomeksi", + "it": "Godot Engine (%s) documentazione in italiano", + "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", + "ru": "Документация Godot Engine (%s) на русском языке", + "uk": "Документація до Godot Engine (%s) українською мовою", + "zh_CN": "Godot Engine (%s) 简体中文文档", +} + +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" exclude_patterns = ["_build"] @@ -78,6 +103,8 @@ html_theme_options = { # 'navigation_depth': 4, # Depth of the headers shown in the navigation bar } +html_title = supported_languages[language] % version + # VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github html_context = { "display_github": True, # Integrate GitHub @@ -85,6 +112,12 @@ html_context = { "github_repo": "godot-docs", # Repo name "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_basepath": "https://docs.godotengine.org/", + "godot_docs_suffix": ".html", + "godot_default_lang": "en", + "godot_canonical_version": "stable", } html_logo = "img/docs_logo.png" @@ -123,6 +156,3 @@ linkcheck_timeout = 10 locale_dirs = ["../sphinx/po/"] gettext_compact = False -# Exclude class reference when marked with tag i18n. -if tags.has("i18n"): - exclude_patterns = ["classes"] diff --git a/robots.txt b/robots.txt index 015c50aad..06d70556d 100644 --- a/robots.txt +++ b/robots.txt @@ -1,7 +1,3 @@ user-agent: * -disallow: /*/3.2 -disallow: /*/3.1 -disallow: /*/3.0 -disallow: /*/2.1 sitemap: https://docs.godotengine.org/sitemap.xml