2 # Shell script to download the latest translations for a given GStreamer
3 # package from translationproject.org
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
10 "af am ar az be bg pt_BR bs ca zh_CN cs cy da de el eo es et eu fa fi fr "\
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"
15 # for testing/debugging:
16 #DOMAINS="es fr hu sv pl xx"
18 # check for 'diff' program
19 diff --version 2>/dev/null >/dev/null
21 echo "==== You must have the 'diff' program installed for this script ===="
25 # check for 'wget' program
26 wget --version 2>/dev/null >/dev/null
28 echo "==== You must have the 'wget' program installed for this script ===="
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 ===="
38 # make sure a package argument was passed to us
40 echo "Usage: $0 PACKAGE, e.g. $0 gst-plugins-good"
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' ?!"
57 DOMAINS_NOT_IN_LINGUAS=""
59 echo "Downloading latest translation files for package $PACKAGE ..."
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 \
75 mv $PO_FILENAME.utf8 $PO_FILENAME
77 echo "**** $d: conversion from $CHARSET to UTF-8 failed ****"
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"
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)"
97 DOMAINS_UPDATED="$DOMAINS_UPDATED $d"
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"
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"
113 echo "$d.po: failure (does probably not exist)"
117 if [ -n "$DOMAINS_UPDATED" ]; then
118 echo "===================================================================="
120 echo "Language domains updated :$DOMAINS_UPDATED"
121 echo "Language domains to git add :$DOMAINS_TO_ADD"
123 echo "Source: http://translationproject.org/latest/$PACKAGE/"
125 if [ -n "$DOMAINS_TO_ADD" ]; then
127 for d in $DOMAINS_TO_ADD; do
128 CMD_STRING="$CMD_STRING po/$d.po"
134 echo "now and add the following domains to the po/LINGUAS file:"
136 echo " $DOMAINS_TO_ADD"
140 echo "===================================================================="
143 if [ -n "$DOMAINS_NOT_IN_LINGUAS" ]; then
145 echo "Existing domains missing from the po/LINGUAS file:"
147 echo " $DOMAINS_NOT_IN_LINGUAS"