"Fossies" - the Fresh Open Source Software Archive

Member "gstreamer-1.16.1/common/download-translations" (19 Apr 2019, 4809 Bytes) of package /linux/misc/gstreamer-1.16.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # Shell script to download the latest translations for a given GStreamer
    3 # package from translationproject.org
    4 
    5 
    6 # DOMAINS based on http://translationproject.org/extra/matrix.html
    7 # We need to check all domains, not only po/LINGUAS, since there might be
    8 # new translations
    9 DOMAINS=\
   10 "af am ar ast az be bg pt_BR bs ca zh_CN cs cy da de el eo es et eu fa fi fr fur "\
   11 "ga en_GB gl gu he hi zh_HK hr hu id is it ja ko ku ky lg lt lv mk mn ms "\
   12 "mt nb ne nl nn or pa pl pt rm ro ru rw sk sl sq sr sv ta tq th tk "\
   13 "tr zh_TW uk ven vi wa xh zu"
   14 
   15 # for testing/debugging:
   16 #DOMAINS="es fr hu sv pl xx"
   17 
   18 # check for 'diff' program
   19 diff --version 2>/dev/null >/dev/null
   20 if [ ! $? ]; then
   21   echo "==== You must have the 'diff' program installed for this script ===="
   22   exit 1
   23 fi
   24 
   25 # check for 'wget' program
   26 wget --version 2>/dev/null >/dev/null
   27 if [ ! $? ]; then
   28   echo "==== You must have the 'wget' program installed for this script ===="
   29   exit 1
   30 fi
   31 
   32 # make sure we're in the top-level directory
   33 if [ ! -d ./po ]; then
   34   echo "==== No ./po directory in the current working directory ===="
   35   exit 1
   36 fi
   37 
   38 # make sure a package argument was passed to us
   39 if [ -z "$1" ]; then
   40   echo "Usage: $0 PACKAGE, e.g. $0 gst-plugins-good"
   41   exit 1
   42 fi
   43 
   44 if test "$1" != "gstreamer" -a \
   45         "$1" != "gst-plugins-base" -a \
   46         "$1" != "gst-plugins-good" -a \
   47         "$1" != "gst-plugins-ugly" -a \
   48         "$1" != "gst-plugins-bad"; then
   49   echo "Unexpected package '$1' ?!"
   50   exit 1
   51 fi
   52 
   53 PACKAGE="$1"
   54 
   55 DOMAINS_TO_ADD=""
   56 DOMAINS_UPDATED=""
   57 DOMAINS_NOT_IN_LINGUAS=""
   58 
   59 echo "Downloading latest translation files for package $PACKAGE ..."
   60 echo
   61 
   62 for d in $DOMAINS
   63 do
   64   PACKAGE_PO_URL_BASE="http://translationproject.org/latest/$PACKAGE"
   65   PO_URL="$PACKAGE_PO_URL_BASE/$d.po"
   66   PO_FILENAME="$PACKAGE.$d.po"
   67   if wget -q -nc -O $PO_FILENAME $PO_URL; then
   68     # we want all .po files in UTF-8 format really, so convert if needed..
   69     CHARSET=`grep Content-Type $PO_FILENAME | sed -e 's/.*charset=\(.*\)\\\\n.*/\1/'`
   70     if test "x$CHARSET" != "xUTF-8" -a "x$CHARSET" != "xutf-8"; then
   71       # note: things like the bugs address will be added back by make update-po
   72       if msguniq $PO_FILENAME --no-location \
   73                               --output-file=$PO_FILENAME.utf8 \
   74                               --to-code=UTF-8; then
   75         mv $PO_FILENAME.utf8 $PO_FILENAME
   76       else
   77         echo "**** $d: conversion from $CHARSET to UTF-8 failed ****"
   78       fi
   79     fi
   80     if [ -f "po/$d.po" ]; then
   81       # ./po/foo.po exists, so let's check if ours matches the latest from the
   82       # translation project website
   83       REVDATE_NEW=`grep PO-Revision-Date $PO_FILENAME`;
   84       REVDATE_OLD=`grep PO-Revision-Date po/$d.po`;
   85       CHARSET_OLD=`grep Content-Type po/$d.po | sed -e 's/.*charset=\(.*\)\\\\n.*/\1/'`
   86       if test "x$REVDATE_NEW" = "x$REVDATE_OLD" -a "x$CHARSET_OLD" = "xUTF-8"; then
   87         # note: source code line markers will be removed later by make upload-po
   88         echo "$d.po: up-to-date"
   89         rm -f $PO_FILENAME
   90       else
   91         mv $PO_FILENAME "po/$d.po"
   92         if test "x$CHARSET_OLD" != "xUTF-8" -a "x$CHARSET_OLD" != "xutf-8"; then
   93           echo "$d.po: update (and charset converted from $CHARSET_OLD to UTF-8)"
   94         else
   95           echo "$d.po: updated"
   96         fi
   97         DOMAINS_UPDATED="$DOMAINS_UPDATED $d"
   98       fi
   99       # make sure domain is listed in LINGUAS
  100       if ! grep $d "po/LINGUAS" >/dev/null 2>/dev/null; then
  101         DOMAINS_NOT_IN_LINGUAS="$DOMAINS_NOT_IN_LINGUAS $d"
  102       fi
  103     else
  104       # ./po/foo.po doesn't exist, but foo.po exists on the translation project
  105       # website, so it's probably a new translation
  106       echo "$d.po: new language"
  107       mv $PO_FILENAME "po/$d.po"
  108       DOMAINS_UPDATED="$DOMAINS_UPDATED $d"
  109       DOMAINS_TO_ADD="$DOMAINS_TO_ADD $d"
  110     fi
  111   else
  112     rm -f $PO_FILENAME
  113     echo "$d.po: failure (does probably not exist)"
  114   fi
  115 done
  116 
  117 if [ -n "$DOMAINS_UPDATED" ]; then
  118   echo "===================================================================="
  119   echo
  120   echo "Language domains updated    :$DOMAINS_UPDATED"
  121   echo "Language domains to git add :$DOMAINS_TO_ADD"
  122   echo
  123   echo "Source: http://translationproject.org/latest/$PACKAGE/"
  124   echo
  125   if [ -n "$DOMAINS_TO_ADD" ]; then
  126     CMD_STRING="git add"
  127     for d in $DOMAINS_TO_ADD; do
  128       CMD_STRING="$CMD_STRING po/$d.po"
  129     done
  130     echo "Please run"
  131     echo
  132     echo "  $CMD_STRING"
  133     echo
  134     echo "now and add the following domains to the po/LINGUAS file:"
  135     echo
  136     echo "  $DOMAINS_TO_ADD"
  137     echo
  138     echo
  139   fi
  140   echo "===================================================================="
  141 fi
  142 
  143 if [ -n "$DOMAINS_NOT_IN_LINGUAS" ]; then
  144   echo
  145   echo "Existing domains missing from the po/LINGUAS file:"
  146   echo
  147   echo "  $DOMAINS_NOT_IN_LINGUAS"
  148   echo
  149   echo
  150 fi
  151 
  152