From 61792e3e31bf919fb5afe988abdfab2f06e97e6d Mon Sep 17 00:00:00 2001 From: Yifei Ding Date: Sat, 19 Mar 2022 13:57:56 -0700 Subject: [PATCH] _klipper3d: Specify mkdocs language config options Signed-off-by: Yifei Ding Signed-off-by: Kevin O'Connor --- docs/_klipper3d/build-translations.sh | 8 +++++++- docs/_klipper3d/mkdocs.yml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/_klipper3d/build-translations.sh b/docs/_klipper3d/build-translations.sh index 3da409db..7094d1d9 100755 --- a/docs/_klipper3d/build-translations.sh +++ b/docs/_klipper3d/build-translations.sh @@ -15,7 +15,7 @@ git clone --depth 1 https://github.com/Klipper3d/klipper-translations ${TRANS_DI # Create new mkdocs-main.yml with language links cp ${MKDOCS_DIR}mkdocs.yml ${MKDOCS_MAIN} while IFS="," read dirname langsite langdesc langsearch; do - sed -i "s%^.*# Alternate language links automatically added here$% - name: ${langdesc}\n link: /${langsite}/\n\0%" ${MKDOCS_MAIN} + sed -i "s%^.*# Alternate language links automatically added here$% - name: ${langdesc}\n link: /${langsite}/\n lang: ${langsite}\n\0%" ${MKDOCS_MAIN} done < <(egrep -v '^ *(#|$)' ${TRANS_FILE}) # Build main English website @@ -50,6 +50,12 @@ while IFS="," read dirname langsite langdesc langsearch; do new_mkdocs_file="${new_docs_dir}_klipper3d/mkdocs-lang-${langsite}.yml" cp "${MKDOCS_MAIN}" "${new_mkdocs_file}" + echo "replace search language" + sed -i "s%^ lang: en$% lang: ${langsearch}%" "${new_mkdocs_file}" + + echo "replace site language" + sed -i "s%^ language: en$% language: ${langsite}%" "${new_mkdocs_file}" + # Build site echo "building site for ${langsite}" mkdir -p "${PWD}/site/${langsite}/" diff --git a/docs/_klipper3d/mkdocs.yml b/docs/_klipper3d/mkdocs.yml index 24015851..b2a59827 100644 --- a/docs/_klipper3d/mkdocs.yml +++ b/docs/_klipper3d/mkdocs.yml @@ -1,5 +1,8 @@ # Main configuration file for mkdocs generation of klipper3d.org website +# Note that the build-translations.sh script expects a certain file +# layout. See that script and the README file for more details. + # Site and directory configuration site_name: Klipper documentation repo_url: https://github.com/Klipper3d/klipper @@ -19,7 +22,8 @@ markdown_extensions: - mdx_truly_sane_lists - mdx_breakless_lists plugins: - search: {} + search: + lang: en mkdocs-simple-hooks: hooks: on_page_markdown: "docs._klipper3d.mkdocs_hooks:transform" @@ -58,6 +62,7 @@ theme: - search.suggest - search.highlight - search.share + language: en extra_css: - _klipper3d/css/extra.css @@ -71,6 +76,7 @@ extra: alternate: - name: English link: / + lang: en # Alternate language links automatically added here # Navigation hierarchy (this should mimic the layout of Overview.md)