aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/l10n.sh
diff options
context:
space:
mode:
Diffstat (limited to 'aux/workflow/l10n.sh')
-rwxr-xr-xaux/workflow/l10n.sh71
1 files changed, 42 insertions, 29 deletions
diff --git a/aux/workflow/l10n.sh b/aux/workflow/l10n.sh
index e1fd3bb..66e452a 100755
--- a/aux/workflow/l10n.sh
+++ b/aux/workflow/l10n.sh
@@ -2,49 +2,62 @@
set -eu
LANGS=
-while getopts 'l:' flag; do
+while getopts 'l:L:' flag; do
case "$flag" in
l)
LANGS="$OPTARG"
;;
+ L)
+ CONTRIBLANGS="$OPTARG"
+ ;;
*)
exit 2
;;
esac
done
shift $((OPTIND - 1))
-if [ -z "$LANGS" ]; then
- echo "Missing LANG" >&2
- exit 2
-fi
-end="\033[0m"
-yellow="\033[0;33m"
-manpage() {
- from_f="$1"
- for l in $LANGS; do
- to_f="$(echo "$from_f" | sed "s/\.en\./.$l./")"
+assert_arg() {
+ if [ -z "$1" ]; then
+ echo "Missing $2" >&2
+ exit 2
+ fi
+}
+
+assert_arg "${LANGS:-}" '-l LANGS'
+for from_f in "$@"; do
+ for lang in $LANGS ${CONTRIBLANGS:-}; do
+ to_f="$(echo "$from_f" | sed "s/\.en\./.$lang./")"
printf 'Generating %s...\n' "$to_f"
- OUT="$(mktemp)"
- po4a-updatepo -f man -m "$from_f" -p "doc/po/$l.po"
- po4a-translate -f man -m "$from_f" -p "doc/po/$l.po" -l "$to_f" -k 0 -v 2>&1 | tee "$OUT" >&2
+ pofile="po/LC_MESSAGES/$from_f/$lang.po"
+ mkdir -p "$(dirname "$pofile")"
- if ! grep -qF ' is 100% translated (' "$OUT"; then
- printf "\n\t${yellow}WARNING${end}!\n Missing translations for %s\n\n" "$to_f" >&2
- fi
+ case "$from_f" in
+ *.en.[1-9].in)
+ po4a-updatepo -f man -m "$from_f" -p "$pofile"
+ po4a-translate -f man -m "$from_f" -p "$pofile" -l "$to_f" -k 0 -v >&2
+ ;;
+ *.en.md)
+ touch "$pofile"
+ md2po --include-codeblocks --quiet --save --po-filepath "$pofile" < "$from_f"
+ po2md --pofiles "$pofile" --quiet --save "$to_f" --wrapwidth 999 < "$from_f"
+ ;;
+ *)
+ echo "Unsupported file format: $from_f" >&2
+ exit 2
+ ;;
+ esac
done
-}
+done
-for f in "$@"; do
- case "$f" in
- *.en.[1-9].in)
- mkdir -p doc/po
- manpage "$f"
- ;;
- *)
- echo "Unsupported file format: $f" >&2
- exit 2
- ;;
- esac
+end="\033[0m"
+yellowb="\033[1;33m"
+for lang in $LANGS; do
+ # shellcheck disable=2044
+ for pofile in $(find po/ -type f -name "$lang.po"); do
+ if LANG=POSIX msgfmt --statistics "$pofile" 2>&1 | grep untranslated; then
+ printf "\n\t${yellowb}WARNING${end}!\n Missing translations for %s\n\n" "$pofile" >&2
+ fi
+ done
done