aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-24 09:14:31 -0300
committerEuAndreh <eu@euandre.org>2021-06-25 11:56:53 -0300
commitf4deaf6bd66ed07cab897002c4cacd2e28027552 (patch)
tree81ccdcc409933ea00fa3c944d5fc0fab5e47231b /aux/workflow
parentaux/workflow/manpages.sh: Add missing suffix to HTML files (diff)
downloadgit-permalink-f4deaf6bd66ed07cab897002c4cacd2e28027552.tar.gz
git-permalink-f4deaf6bd66ed07cab897002c4cacd2e28027552.tar.xz
aux/workflow/assert-spelling.sh: Add; init dictionaries; fix spelling
- aux/workflow/l10n.sh: fix handling of $@; - Makefile: remove circular dependency between dev-check and public by adding the "l10n-gen" target.
Diffstat (limited to 'aux/workflow')
-rwxr-xr-xaux/workflow/assert-manpages.sh2
-rwxr-xr-xaux/workflow/assert-spelling.sh68
-rwxr-xr-xaux/workflow/l10n.sh32
3 files changed, 86 insertions, 16 deletions
diff --git a/aux/workflow/assert-manpages.sh b/aux/workflow/assert-manpages.sh
index 7254d60..7f12626 100755
--- a/aux/workflow/assert-manpages.sh
+++ b/aux/workflow/assert-manpages.sh
@@ -111,7 +111,7 @@ Soumettre un bogue dans la
liste
de diffusion
.ME .
-Utilise le sujèt "\f(CR[$PROJECT] BUG ou TASK:
+Utilise le sujet "\f(CR[$PROJECT] BUG ou TASK:
<description>\fR".
.IP \(bu
Parcourir les bogues
diff --git a/aux/workflow/assert-spelling.sh b/aux/workflow/assert-spelling.sh
new file mode 100755
index 0000000..ff1df2a
--- /dev/null
+++ b/aux/workflow/assert-spelling.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+set -eu
+
+sort_dicts() {
+ for f in doc/spelling/*.txt; do
+ if ! LANG=POSIX sort "$f" | diff - "$f"; then
+ if [ "$IN_PLACE" = true ]; then
+ OUT="$(mktemp)"
+ LANG=POSIX sort "$f" | uniq > "$OUT"
+ mv "$OUT" "$f"
+ else
+ echo "The $f dictionary is unsorted. To fix it, run:" >&2
+ echo " sh aux/workflow/assert-spelling.sh -i" >&2
+ exit 1
+ fi
+ fi
+ done
+}
+
+IN_PLACE=false
+while getopts 'l:i' flag; do
+ case "$flag" in
+ l)
+ LANGS="$OPTARG"
+ ;;
+ i)
+ IN_PLACE=true
+ sort_dicts
+ exit
+ ;;
+ *)
+ exit 2
+ ;;
+ esac
+done
+if [ -z "${LANGS:-}" ]; then
+ echo 'Missing -l LANGS' >&2
+ exit 2
+fi
+
+mkdir -p doc/spelling
+eval "touch doc/spelling/{international,$(echo "$LANGS" | tr ' ' ,)}.txt"
+
+get_lang() {
+ grep lang=.. "$1" | \
+ head -n1 | \
+ awk '
+ match($0, /lang="(..)"/) {
+ print substr($0, RSTART+length("lang=\""), 2)
+ }
+ '
+}
+
+ACC="$(mktemp)"
+# shellcheck disable=2044
+for f in $(find public -type f -name '*.html'); do
+ l="$(get_lang "$f")"
+ CURR_DICT="$(mktemp)"
+ cat doc/spelling/international.txt "doc/spelling/$l.txt" | sort | uniq > "$CURR_DICT"
+ hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$ACC" >&2
+done
+
+if [ -s "$ACC" ]; then
+ printf '\n\tMispelled words detected by hunspell above.\n\n' >&2
+ exit 1
+fi
+
+sort_dicts
diff --git a/aux/workflow/l10n.sh b/aux/workflow/l10n.sh
index ece154e..207237d 100755
--- a/aux/workflow/l10n.sh
+++ b/aux/workflow/l10n.sh
@@ -18,8 +18,23 @@ if [ -z "$LANGS" ]; then
exit 2
fi
-# shellcheck disable=2044
-for f in $(find "$@" -not -name '*.en.*'); do
+manpage() {
+ from_f="$1"
+ for l in $LANGS; do
+ to_f="$(echo "$from_f" | sed "s/\.en\./.$l./")"
+
+ printf 'Generating %s...\n' "$to_f"
+ OUT="$(mktemp)"
+ po4a-updatepo -f man -m "$from_f" -p "po/$l.po"
+ po4a-translate -f man -m "$from_f" -p "po/$l.po" -l "$to_f" -k 0 -v 2>&1 | tee "$OUT" >&2
+
+ if ! grep -qF ' is 100% translated (' "$OUT"; then
+ printf '\n\tWARNING!\n Missing translations for %s\n\n' "$to_f" >&2
+ fi
+ done
+}
+
+for f in "$@"; do
case "$f" in
*.en.[1-9].in)
manpage "$f"
@@ -30,16 +45,3 @@ for f in $(find "$@" -not -name '*.en.*'); do
;;
esac
done
-
-manpage() {
- from_f="$1"
- for l in $LANGS; do
- to_f="$(echo "$from_f" | sed "s/\.en\./.$l./")"
- po4a-updatepo -f man -m "$from_f" -p "po/$l.po"
- OUT="$(po4a-translate -f man -m "$from_f" -p "po/$l.po" -l "$to_f" -k 0 -v 2>&1)"
- echo "$OUT" >&2
- if ! echo "$OUT" | grep -qF ' is 100% translated ('; then
- printf '\n\tWARNING!\n Missing translations for %s\n\n' "$to_f" >&2
- fi
- done
-}