feat: Add build.sh/dev.sh with LANG arg

This commit is contained in:
c c 2026-09-11 12:04:24 +02:00
commit 262afbb425
5 changed files with 32 additions and 12 deletions

View file

@ -5,8 +5,19 @@ basedir="$(realpath "$basedir")"
cd "$basedir"
name="$(basename "$(pwd)")"
if ! typst compile --root .. ./main.typ ./"$name".pdf; then
echo "Failed to compile $name/main.typ. Please fix errors and run me again."
# Check if we want to run against a certain translation
if [ $# -lt 1 ]; then
echo "Please specify the language you want to build (eg. fr)"
exit 1
fi
TARGETLANG="$1"
SOURCEFILE="main.${TARGETLANG}.typ"
TARGETFILE="$name".$TARGETLANG.pdf
TARGETFILEBOOK="$name".${TARGETLANG}-book.pdf
if ! typst compile --root .. ./"$SOURCEFILE" ./"$TARGETFILE"; then
echo "Failed to compile "$name"/"$SOURCEFILE". Please fix errors and run me again."
exit 1
fi
@ -18,7 +29,7 @@ if ! command -v pdfbook2; then
fi
t="$(mktemp --suffix=.pdf)"
typst compile --input format=booklet --root .. ./main.typ "$t"
typst compile --input format=booklet --root .. ./"$SOURCEFILE" "$t"
# Need to be in the folder there for it to work, otherwise it
# tries to rename from current partition to /tmp which of course fails
@ -30,6 +41,5 @@ cd "$parent"
pdfbook2 --paper=a4paper "$t" --no-crop --outer-margin=0 --inner-margin=0 --top-margin=0 --bottom-margin=0
cd "$basedir"
newFinalFile="$name"-book.pdf
cp "$newFile" "$newFinalFile"
echo "Booklet available in $newFinalFile"
cp "$newFile" "$TARGETFILEBOOK"
echo "Booklet available in $TARGETFILEBOOK"