peertube-plugin-livechat/doc-generate-missing-translations.sh
John Livingston e17257a90f
#117 part 1: New documentation website (#151)
This commit concerns the first subtask of this issue: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/117

It provide a brand new documentation website, that replace the previous markdown files.
The website is auto-generated using CI/CD, and can be found here: https://johnxlivingston.github.io/peertube-plugin-livechat/
2023-02-13 17:58:06 +01:00

33 lines
1014 B
Bash

#!/bin/bash
set -euo pipefail
function getLangs() {
grep -P '\[Languages.\w+\]' support/documentation/config.toml | sed -E 's/^.*\.(\w+)\].*$/\1/' | grep -v en
}
function createMissingFile() {
source_file=$1
wanted_file=$2
echo " creating $wanted_file from $source_file"
# getting everything between +++ and +++:
sed -n '/\+\+\+/,/\+\+\+/p' "$source_file" > "$wanted_file"
# Adding the warning notice:
echo "
{{% notice warning %}}
This page is not yet translated in your language, please refer to the english version. You can switch to it by using the language selector in the left menu.
{{% /notice %}}" >> "$wanted_file"
}
find support/documentation/content -name '*.en.md' | while read source_file; do
echo "File $source_file:"
getLangs | while read lang; do
wanted_file=$(echo "$source_file" | sed -E "s/.en.md\$/.$lang.md/")
if test -f $wanted_file; then
echo " File $wanted_file OK"
else
createMissingFile "$source_file" "$wanted_file"
fi
done
done