aboutsummaryrefslogtreecommitdiffstats
path: root/docs/_klipper3d/fetch-translations.sh
diff options
context:
space:
mode:
Diffstat (limited to 'docs/_klipper3d/fetch-translations.sh')
-rwxr-xr-xdocs/_klipper3d/fetch-translations.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/_klipper3d/fetch-translations.sh b/docs/_klipper3d/fetch-translations.sh
new file mode 100755
index 00000000..79352f60
--- /dev/null
+++ b/docs/_klipper3d/fetch-translations.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# Modify the file structure before running mkdocs
+# This is a make shift script before the current structure of
+# Klipper-translations can be directly utilized by mkdocs
+# Usage: pre-mkdocs.sh <lang_directory_name> <target_lang_name>
+
+#git clone --depth 1 https://github.com/Klipper3d/klipper-translations
+
+while IFS="," read dirname langname langdesc note; do
+ # move and rename markdown files
+ local_dir="klipper-translations/docs/locales/$dirname"
+ echo "Moving $dirname to $langname"
+ for file in "$local_dir"/*.md; do
+ mdfilename="${file/$local_dir\//}"
+ mv "$file" "./docs/${mdfilename//.md/.${langname}.md}"
+ done
+
+ # manually replace index.md if a manual-index.md exist
+ manual_index="./docs/manual-index.$langname.md"
+
+ if [[ -f "$manual_index" ]];then
+ mv "$manual_index" "./docs/index.${langname}.md"
+ echo "replaced index.${langname}.md with $manual_index"
+ else
+ echo "Manually translated index file for $dirname not found!"
+ fi
+
+ # add to translations.yml
+ echo " ${langname}: ${langdesc}" >> ./docs/_klipper3d/translations.yml
+done < <(egrep -v '^ *(#|$)' ./klipper-translations/active_translations | tail -n +2)