diff --git a/_layouts/base.html b/_layouts/base.html
index 11856cc26..84484249f 100644
--- a/_layouts/base.html
+++ b/_layouts/base.html
@@ -1,4 +1,4 @@
-{%- if page.layout == "manual" and page.language -%}
+{%- if page.language -%}
{%- else -%}
diff --git a/_layouts/tutorial.html b/_layouts/tutorial.html
index ea034a5ee..5d0baed21 100644
--- a/_layouts/tutorial.html
+++ b/_layouts/tutorial.html
@@ -6,6 +6,22 @@
-
+
+ {%- if page_language != "en" and current_tutorial -%}
+ {%- capture urlprefix -%}/{{ language.urlprefix }}/{%- endcapture -%}
+
+
This translation is community contributed and may not be up to date. We only maintain the English version of the documentation. Read this tutorial in English
+
+ {%- endif -%}
+
{%- if page.difficulty -%}
{{ page.difficulty }}
{%- endif -%}
{% include anchor_headings.html html=content anchorClass="anchor-link" %}
+
+ {%- if site.data.languageindex.size > 1 and current_tutorial -%}
+
+
Languages
+
+ {%- for l in site.data.languageindex -%}
+ {%- if l.active and current_tutorial.languages contains l.language -%}
+
+ {%- if l.language == "en" -%}
+ {{ l.name }}
+ {%- elsif current_tutorial.languages contains l.language -%}
+ {{ l.name }}
+ {%- endif -%}
+
+ {%- endif -%}
+ {%- endfor -%}
+
+
+ {%- endif -%}
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
- {% include secondary_button.html text="GITHUB" link="https://github.com/defold/doc" %}
+ {% include secondary_button.html text="GITHUB" link=github_link %}
diff --git a/update.py b/update.py
index a9e0656f4..453cdfbea 100755
--- a/update.py
+++ b/update.py
@@ -319,6 +319,19 @@ def get_language_specific_dir(language, dir):
dir = os.path.join(language, dir)
return dir
+
+def get_index_item_languages(item, languages):
+ item_languages = []
+ if not item["path"].startswith("http"):
+ path = item["path"][1:]
+ # foo/bar/#anchor -> foo/bar
+ # foo/bar#anchor -> foo/bar
+ path = re.sub(r"/?\#.*", "", path)
+ for language in languages["languages"].keys():
+ if os.path.exists(get_language_specific_dir(language, path + ".md")):
+ item_languages.append(language)
+ return item_languages
+
def update_file_links_with_lang(filename, pattern, language):
# Open the file and read its content
with open(filename, 'r') as f:
@@ -485,13 +498,22 @@ def process_docs(download = False):
for filename in find_files(shared_includes_dst_dir, "*.md"):
process_doc_file(filename, language)
- print("...tutorials")
- tutorials_src_dir = os.path.join(DOC_DIR, "docs", "en", "tutorials")
- tutorials_dst_dir = "tutorials"
- rmcopytree(tutorials_src_dir, tutorials_dst_dir)
- for filename in find_files(tutorials_dst_dir, "*.md"):
- process_doc_file(filename, "en")
- append_frontmatter(filename, { "layout": "tutorial" })
+ for language in languages["languages"].keys():
+ print("...tutorials ({})".format(language))
+ tutorials_src_dir = os.path.join(DOC_DIR, "docs", language, "tutorials")
+ if os.path.exists(tutorials_src_dir):
+ tutorials_dst_dir = get_language_specific_dir(language, "tutorials")
+ rmcopytree(tutorials_src_dir, tutorials_dst_dir)
+ for filename in find_files(tutorials_dst_dir, "*.md"):
+ process_doc_file(filename, language)
+ append_frontmatter(filename, {
+ "language": language,
+ "layout": "tutorial",
+ })
+ if language != "en":
+ update_file_links_with_lang(filename, r'/manuals/[^)#]+', language)
+ update_file_links_with_lang(filename, r'/tutorials/[^)#]+', language)
+ replace_in_file(filename, r"\.\.\/images\/", r"/tutorials/images/")
print("...courses")
courses_src_dir = os.path.join(DOC_DIR, "docs", "en", "courses")
@@ -505,15 +527,10 @@ def process_docs(download = False):
print("...index (incl. languages)")
for section in index["navigation"]["manuals"]:
for item in section["items"]:
- item["languages"] = []
- if not item["path"].startswith("http"):
- path = item["path"][1:]
- # foo/bar/#anchor -> foo/bar
- # foo/bar#anchor -> foo/bar
- path = re.sub(r"/?\#.*", "", path)
- for language in languages["languages"].keys():
- if os.path.exists(get_language_specific_dir(language, path + ".md")):
- item["languages"].append(language)
+ item["languages"] = get_index_item_languages(item, languages)
+ for item in index["navigation"]["tutorials"]:
+ if not item["path"].startswith("http"):
+ item["languages"] = get_index_item_languages(item, languages)
write_as_json(index_file, index)
print("...shared images")