aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-06-10 14:09:41 +0100
committerSilvio Rhatto <rhatto@riseup.net>2024-06-10 14:09:41 +0100
commitd5f4b967422ed898d15aa5941f777155ddb3e3c5 (patch)
tree83c0c34e47c4e707fea6b1316bc4a3408485446f /bin
parent0f0f4bbd9c6cba0fbf196de47e2baed7741391c3 (diff)
downloadbookup-d5f4b967422ed898d15aa5941f777155ddb3e3c5.tar.gz
bookup-d5f4b967422ed898d15aa5941f777155ddb3e3c5.tar.bz2
Feat: towards localization support
Diffstat (limited to 'bin')
-rwxr-xr-xbin/compile-book13
-rwxr-xr-xbin/compile-notes13
2 files changed, 22 insertions, 4 deletions
diff --git a/bin/compile-book b/bin/compile-book
index 2907e98..5c8447a 100755
--- a/bin/compile-book
+++ b/bin/compile-book
@@ -7,11 +7,20 @@
BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."
-STRUCTURE="structure/book"
CONTENT="content/sections"
OUTPUT="${1:-book}"
REVISION="$2"
DATE="$3"
+LANG="`grep lang _common.yml _book.yml _notes.yml 2> /dev/null | tail -1 | cut -d : -f 3 | sed -e 's/"//g' -e 's/ //g'`"
+
+# Set the language
+if [ -z "$LANG" ]; then
+ LANG="en"
+fi
+
+# Set structure and templates
+STRUCTURE="structure/book/$LANG"
+TEMPLATES="templates/book/$LANG"
# Remove any dangling output files
rm -f $OUTPUT.md $OUTPUT.Rmd
@@ -42,7 +51,7 @@ if [ -d "$CONTENT" ]; then
find $CONTENT -type f | grep '\.md$' | sort | while read file; do
cat $file >> $OUTPUT.md
echo "" >> $OUTPUT.md
- cat $BASEDIR/templates/book/references.md >> $OUTPUT.md
+ cat $BASEDIR/$TEMPLATES/references.md >> $OUTPUT.md
echo "" >> $OUTPUT.md
done
fi
diff --git a/bin/compile-notes b/bin/compile-notes
index 24c98ea..c56c56b 100755
--- a/bin/compile-notes
+++ b/bin/compile-notes
@@ -7,11 +7,20 @@
BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."
-STRUCTURE="structure/notes"
CONTENT="content/notes"
OUTPUT="${1:-notes}"
REVISION="$2"
DATE="$3"
+LANG="`grep lang _common.yml _book.yml _notes.yml 2> /dev/null | tail -1 | cut -d : -f 3 | sed -e 's/"//g' -e 's/ //g'`"
+
+# Set the language
+if [ -z "$LANG" ]; then
+ LANG="en"
+fi
+
+# Set structure and templates
+STRUCTURE="structure/notes/$LANG"
+TEMPLATES="templates/notes/$LANG"
# Remove any dangling output files
rm -f $OUTPUT.md
@@ -46,7 +55,7 @@ if [ -d "$CONTENT" ]; then
fi
# Bibliography section
-cat $BASEDIR/templates/notes/bibliography.md >> $OUTPUT.md
+cat $BASEDIR/$TEMPLATES/bibliography.md >> $OUTPUT.md
# Revision information
sed -i -e "s|%%revision%%|$REVISION|g" -e "s|%%date%%|$DATE|g" $OUTPUT.md