#!/bin/bash

# usage: tranlators.sh LAST_RELEASE_TAG

# Changed so that the list comes out sorted by .po file name
# Mariano Suárez-Alvarez, Tue Feb 17 16:59:28 ART 2004

# Changed to work with svn instead of cvs by chpe@gnome.org

if [ ! $# -eq 1 ] ; then
        echo "usage: $0 LAST_RELEASE_REVISION"
        exit 1;
fi

export LANG=C

root_xsl=$(tempfile)
cat << EOF > $root_xsl
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="text" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:value-of select="/info/entry/repository/root" />
</xsl:template>
</xsl:stylesheet>
EOF

rev_xsl=$(tempfile)
cat << EOF > $rev_xsl
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method="text" indent="no" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:value-of select="/info/entry/commit/@revision" />
</xsl:template>
</xsl:stylesheet>
EOF

repo_root=$(svn info --xml . | xsltproc $root_xsl -)
repo_tag=$repo_root/tags/$1

repo_this_rev=$(svn info --xml . | xsltproc $rev_xsl -)
repo_tag_rev=$(svn info --xml $repo_tag | xsltproc $rev_xsl -)

rm -f $root_xsl $rev_xsl

svn diff -r$repo_tag_rev:$repo_this_rev po/ChangeLog | \
  (awk  '/\+.*[a-z][a-zA-Z@_]*\.po/ { print gensub ("[:,]", "\n", "g", $3); }' | \
    while read file; do
  if [ -z "$file" ]; then continue; fi
  echo "(${file%%.po})" $(grep "Last-Translator" po/$file | sed -e 's/"Last-Translator:  *\(.*\)  *<.*/\1/') 
done) | sort | uniq | sed -e 's/\((.*)\) \(.*\)/\2 \1/'

