diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-17 11:54:34 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-17 11:54:34 +0000 |
commit | 2e3ccdfcdae0d9481984985e45df37ffbc4c61a8 (patch) | |
tree | 07ab05c8d2ef17d8a71ca3bb0a3d0e4b43941604 /bootstrap | |
parent | 8398ada9fb577f44c27a14ae06b12837d0044f63 (diff) | |
download | mailfromd-2e3ccdfcdae0d9481984985e45df37ffbc4c61a8.tar.gz mailfromd-2e3ccdfcdae0d9481984985e45df37ffbc4c61a8.tar.bz2 |
Get translations from the TP.
git-svn-id: file:///svnroot/mailfromd/trunk@1447 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'bootstrap')
-rw-r--r-- | bootstrap | 184 |
1 files changed, 175 insertions, 9 deletions
@@ -3,6 +3,8 @@ ## Configuration ############################ +GNULIB_DATE=2007-05-12 + MODLIST="argp\ fprintftime\ gettext\ @@ -17,6 +19,8 @@ MODLIST="argp\ strtok_r\ version-etc" +MODAVOID="xalloc-die openat-die" + # Other locale categories that need message catalogs. EXTRA_LOCALE_CATEGORIES= @@ -42,16 +46,39 @@ COPYRIGHT_HOLDER="Sergey Poznyakoff" # Translation Project URL, for the registry of all projects # and for the translation-team master directory. # (for future use) -#TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' -#TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/' - -# Currently here -TP_URL=ftp://download.gnu.org.ua/pub/users/gray/po/mailfromd/ +TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain=' +TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/' ############################ ## Implementation ############################ +usage() { + echo >&2 "\ +Usage: $0 [OPTION]... GNULIB_DIR +Bootstrap this package from the checked-out sources. + + --copy Copy files instead of creating symbolic links. + --force Attempt to bootstrap even if the sources seem + not to have been checked out. + --skip-po Do not download po files. + --update-po[=LANG] Update po file(s) and exit. + +Local defaults can be provided by placing the file \`.bootstrap' in the +current working directory. The file is read, comments and empty lines are +removed, shell variables expanded and the result is prepended to the command +line options. + +Running without arguments will suffice in most cases. +" +} + +# Read local configuration file +if [ -r .bootstrap ]; then + echo "$0: Reading configuration file .bootstrap" + eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*" +fi + extract_package_name=' /^AC_INIT(/{ /.*,.*,.*,/{ @@ -69,14 +96,69 @@ extract_package_name=' } ' package=`sed -n "$extract_package_name" configure.ac` || exit + +# Whether to use copies instead of symlinks. +copy=false + +GNULIB_OPTION= +DOWNLOAD_PO= + +for option +do + case $option in + --help) + usage + exit;; + --skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition. + DOWNLOAD_PO=skip;; + --update-po=*) + DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;; + --update-po) + DOWNLOAD_PO=only;; + --copy) + copy=true;; + -*) + echo >&2 "$0: $option: unknown option" + exit 1;; + *) + if [ -n "$NULIB_OPTION" ]; then + echo "$0: gnulib directory specified twice">&2 + exit 1 + fi + GNULIB_DIR=$option;; + esac +done + +datecmp() { + test `echo "1 $1 +2 $2" | tr '-' ' ' | sort -n -k2 -k3 -k4 -k1 | sed -n '1s/ .*//p'` -eq 1 +} + +if [ -n "$GNULIB_DIR" ]; then + if [ -d "$GNULIB_DIR" ]; then + PATH="$GNULIB_DIR:$PATH" + if [ -r "$GNULIB_DIR/ChangeLog" ]; then + GNULIB_REV=`sed '/^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/q' "$GNULIB_DIR/ChangeLog"` + if datecmp "$GNULIB_DATE" "$GNULIB_REV"; then :; + else + echo "$0: Gnulib version is too old: $GNULIB_REV">&2 + echo "$0: It should not be older than $GNULIB_DATE">&2 + echo "$0: Please, update gnulib and retry">&2 + exit + fi + else + echo "$0: No $GNULIB_DIR/ChangeLog file found">&2 + fi + else + echo "$0: specified gnulib location is not a directory">&2 + fi +fi + echo "$0: Bootstrapping $package" echo "$0: Running autopoint" autopoint -f || exit 1 -echo "$0: Importing gnulib files ..." -gnulib-tool --import --avoid xalloc-die --avoid openat-die $MODLIST - # Create gettext configuration. echo "$0: Creating po/Makevars from po/Makevars.template ..." rm -f po/Makevars @@ -100,7 +182,91 @@ sed ' '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} } ' po/Makevars.template >po/Makevars - + +# 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" +} + +save_LC_ALL="$LC_ALL" +LC_ALL=C +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 +LC_ALL="$save_LC_ALL" + +case $DOWNLOAD_PO in +'skip') + ;; +'') + get_translations po $package || exit + ;; +'only') + get_translations po $package + exit + ;; +*.po) + get_translations po $package "$DOWNLOAD_PO" + exit + ;; +*) + get_translations po $package "${DOWNLOAD_PO}.po" + exit +esac + +echo "$0: Importing gnulib files ..." +if [ -n "$MODAVOID" ]; then + gnulib_tool_options="`echo $MODAVOID | sed 's/\([^ ][^ ]*\)/--avoid &/g'`" +fi + +gnulib-tool --import $gnulib_tool_options $MODLIST + echo "$0: Reconfiguring ..." for command in \ |