diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/apply-translations.sh | 7 | ||||
-rwxr-xr-x | scripts/assert-spelling.sh | 19 | ||||
-rwxr-xr-x | scripts/extract-translations.sh | 11 |
3 files changed, 15 insertions, 22 deletions
diff --git a/scripts/apply-translations.sh b/scripts/apply-translations.sh index 291de76..1148b60 100755 --- a/scripts/apply-translations.sh +++ b/scripts/apply-translations.sh @@ -1,11 +1,8 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do l="$(grep '^lang: ..$' "$f" | awk '{print $2}')" - if [[ "$l" != 'en' ]]; then + if [ "$l" != 'en' ]; then ref="$(grep '^ref: ' "$f" | awk '{print $2}')" # shellcheck disable=2046 FROM=$(find $(find . -name '*.md' -exec grep -l "^ref: $ref$" {} \;) -exec grep -l '^lang: en$' {} \;) diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh index 615fddc..f4ab58e 100755 --- a/scripts/assert-spelling.sh +++ b/scripts/assert-spelling.sh @@ -1,12 +1,9 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu export LANG=C.UTF-8 for DICT in scripts/spelling/*.txt; do - diff <(sort "$DICT") "$DICT" || { + sort "$DICT" | diff - "$DICT" || { echo "The $DICT dictionary is unsorted. To fix it, run:" >&2 echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2 exit 1 @@ -14,16 +11,18 @@ for DICT in scripts/spelling/*.txt; do done OUT="$(mktemp)" -shopt -s globstar jekyll build --future --trace -for f in _site/**/*.html; do - if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then +# shellcheck disable=2044 +for f in $(find _site -type f -name '*.html'); do + if ! echo "$f" | grep -E '^_site/vendor/' > /dev/null; then l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" - hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT" + CURR_DICT="$(mktemp)" + cat scripts/spelling/international.txt "scripts/spelling/$l.txt" > "$CURR_DICT" + hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT" fi done -if [[ -s "$OUT" ]]; then +if [ -s "$OUT" ]; then printf "\nvvv Mispelled words detected by hunspell.\n\n" cut -d\ -f2- < "$OUT" | sort | uniq printf "\n^^^\n" >&2 diff --git a/scripts/extract-translations.sh b/scripts/extract-translations.sh index 13fc160..ea4b0f5 100755 --- a/scripts/extract-translations.sh +++ b/scripts/extract-translations.sh @@ -1,14 +1,11 @@ -#!/usr/bin/env bash -set -Eeuo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")" -cd ../ +#!/bin/sh -eu -TRANSLATIONS=(pt fr eo) +TRANSLATIONS='pt fr eo' for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do file_lang="$(grep '^lang: ..$' "$f" | awk '{print $2}')" - if [[ "$file_lang" = 'en' ]]; then - for l in "${TRANSLATIONS[@]}"; do + if [ "$file_lang" = 'en' ]; then + for l in $TRANSLATIONS; do OUT="locale/$l/LC_MESSAGES/${f%.md}.po" mkdir -p "$(dirname "$OUT")" md2po "$f" --include-codeblocks --quiet --save --po-filepath "$OUT" |