#! /bin/sh # Bootstrap this package from CVS. # Copyright (C) 2003-2007, 2009-2014, 2019-2022 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Written by Paul Eggert and Sergey Poznyakoff. # Ensure file names are sorted consistently across platforms. # Also, ensure diagnostics are in English, e.g., "wget --help" below. LC_ALL=C export LC_ALL # Translation Project URL, for the registry of all projects # and for the translation-team master directory. TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/' package="parted" # Get translations. get_translations() { subdir=$1 domain=$2 po_file=$3 case $WGET_COMMAND in '') echo "$0: wget not available; skipping translations";; ?*) echo "$0: getting ${po_file:-translations} into $subdir for $domain..." && case $po_file in '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);; esac && $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" && sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" | sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | awk -F. ' { if (lang && $1 != lang) print lang, ver } { lang = $1; ver = substr($0, index($0, ".") + 1) } END { if (lang) print lang, ver } ' | awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" ' { lang = $1 if (po_file && po_file != (lang ".po")) next ver = $2 urlfmt = "" printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\'' &&\n", subdir, lang, lang, domain, ver, lang printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang printf " rm -f %s/%s.po; }; } &&\n", subdir, lang } END { print ":" } ' | WGET_COMMAND="$WGET_COMMAND" sh;; esac && ls "$subdir"/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && rm -f "$subdir/$domain.html" } case `wget --help` in *'--no-cache'*) WGET_COMMAND='wget -nv --no-cache';; *'--cache=on/off'*) WGET_COMMAND='wget -nv --cache=off';; *'--non-verbose'*) WGET_COMMAND='wget -nv';; *) WGET_COMMAND='';; esac get_translations po $package