From f4deaf6bd66ed07cab897002c4cacd2e28027552 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 24 Jun 2021 09:14:31 -0300 Subject: 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. --- aux/workflow/assert-manpages.sh | 2 +- aux/workflow/assert-spelling.sh | 68 +++++++++++++++++++++++++++++++++++++++++ aux/workflow/l10n.sh | 32 ++++++++++--------- 3 files changed, 86 insertions(+), 16 deletions(-) create mode 100755 aux/workflow/assert-spelling.sh (limited to 'aux/workflow') 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: \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 -} -- cgit v1.2.3