#!/bin/sh set -eu LANGS= while getopts 'l:' flag; do case "$flag" in l) LANGS="$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./")" 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 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 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 done