Skip to content

Instantly share code, notes, and snippets.

@oscarfonts
Created June 3, 2012 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarfonts/2864567 to your computer and use it in GitHub Desktop.
Save oscarfonts/2864567 to your computer and use it in GitHub Desktop.
Script per automatitzar la revisió de traduccions d'OSGeo-Live
###########################################################################
# Script per automatitzar la revisió de traduccions d'OSGeo-Live
###########################################################################
#
# Converteix a UTF8, treu el BOM, converteix CRLF a UNIX, copia els nous
# continguts al checkout local del repo, compila els html i els obre en FF.
#
# Llavors cal: revisar l'aspecte visual de cada document, corregir-lo si
# convé, i fer 'svn commit'.
#
###########################################################################
# (c) Oscar Fonts 2012, released under "Do What You Fucking Want" terms
###########################################################################
TRANSLANG="ca"
SVNREPO=~/Documents/Geoinquiets/OSGeoLive/doc
ENCODING="utf-8"
# Remove all symlinks
find -L $SVNREPO -xtype l -print0 | xargs -0 --no-run-if-empty rm
# Update SVN
echo "Actualitzant svn repo"
svn up $SVNREPO
# Process each rst doc
echo "Processant fitxers rst del Dropbox"
find -name "*.rst" | while read -r DOC
do
echo -e "\033[32m$DOC\033[0m"
# Detect encoding and convert if needed
DOC_ENCODING=`file -bi $DOC | sed -e 's/.*[ ]charset=//'`
if [ $DOC_ENCODING != $ENCODING ]
then
echo -e "\033[31m - Codificat com a $DOC_ENCODING. Convertint a $ENCODING \033[0m"
iconv -f $DOC_ENCODING -t $ENCODING $DOC > $DOC.temp
mv -f $DOC.temp $DOC
fi
# Remove BOM
sed -i '1 s/^\xef\xbb\xbf//' $DOC
# Set line feeds to UNIX format
dos2unix -q $DOC
# Copy to svnrepo
DEST_EN=$SVNREPO/en/${DOC/.\//}
DEST=$SVNREPO/$TRANSLANG/${DOC/.\//}
if [ -f $DEST_EN ]
then
echo " - Copiant $DOC a $DEST"
rm $DEST
svn cp $DEST_EN $DEST
cp -f $DOC $DEST
mv $DOC $DOC.bak
fi
done
# build docs
cd $SVNREPO
make html
# open in FF
firefox -new-tab _build/html/en/index.html &
firefox -new-tab _build/html/$TRANSLANG/index.html &
firefox -new-tab https://docs.google.com/spreadsheet/ccc?key=0AlRFyY1XenjJdFRDbjFyWHg1MlNTRm10QXk0UWEzWlE&authkey=CPTB6uIE&pli=1#gid=32 &
echo "Recorda fer el 'svn commit'!!"
@jsanz
Copy link

jsanz commented Jul 14, 2012

This has to be executed on a folder out of the repo where your rst files live right? (dropbox or whatever)

@oscarfonts
Copy link
Author

Yep, has to be run in the same tree where .rst files live (Dropbox in our case), as per line 27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment