From 67f7c956239a7bc811a1d655d389666048e45fc3 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 27 Jun 2021 22:06:40 -0300 Subject: Translate CHANGELOG.md adn README.md Partially implements #task-7c5cd2aa-6d92-0423-bfa7-81f2e8436586. As mentioned in the task, instead of making "README.md" as symlink to "README.en.md", "README.md" is kept as it is, as the translated file doesn't need to live in the repository. The same goes for the "CHANGELOG.md" file. --- aux/workflow/l10n.sh | 56 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'aux/workflow/l10n.sh') diff --git a/aux/workflow/l10n.sh b/aux/workflow/l10n.sh index e1fd3bb..89f2a6e 100755 --- a/aux/workflow/l10n.sh +++ b/aux/workflow/l10n.sh @@ -1,6 +1,8 @@ #!/bin/sh set -eu +mkdir -p doc/po + LANGS= while getopts 'l:' flag; do case "$flag" in @@ -18,33 +20,39 @@ if [ -z "$LANGS" ]; then 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./")" +po() { + format="$1" + from_f="$2" + to_f="$3" + lang="$4" + po4a-updatepo -M UTF-8 -f "$format" -m "$from_f" -p "doc/po/$lang.po" -v --previous + po4a-translate -M UTF-8 -f "$format" -m "$from_f" -p "doc/po/$lang.po" -v -L UTF-8 -l "$to_f" -k 0 >&2 +} +for from_f in "$@"; do + for lang in $LANGS; 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 - 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) + po man "$from_f" "$to_f" "$lang" + ;; + *.en.md|*.en.msg) + po text "$from_f" "$to_f" "$lang" + ;; + *) + 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 + if LANG=POSIX msgfmt --statistics "doc/po/$lang.po" 2>&1 | grep translated; then + printf "\n\t${yellowb}WARNING${end}!\n Missing translations for %s\n\n" "doc/po/$lang.po" >&2 + fi done -- cgit v1.2.3