Created
March 12, 2011 22:29
-
-
Save bradymiller/867634 to your computer and use it in GitHub Desktop.
Script to build OpenEMR translation tables from most current Google Docs Spreadsheet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright (C) 2011 Brady Miller <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or | |
# modify it under the terms of the GNU General Public License | |
# as published by the Free Software Foundation; either version 2 | |
# of the License, or (at your option) any later version. | |
# | |
# Script to test most current Google Docs OpenEMR Translation Spreadsheet. | |
# | |
# Create and change into working directory | |
rm /git/translations/* | |
rmdir /git/translations | |
mkdir /git/translations | |
cd /git/translations | |
# Get the tsv format google doc spreadsheet | |
outputStuff=$(wget --no-check-certificate -O spreadsheet.tsv "https://spreadsheets.google.com/ccc?key=0AtTW60zHo6HzcGg0UE9JMGJHM1NsSWpuYkh0Snl4Q0E&output=txt" 2>&1) | |
if [ ! -f spreadsheet.tsv ]; then | |
#Unable to download file, so error out script | |
echo "Unable to connect to google docs, so quitting" | |
exit | |
fi | |
# Get and set the building script from within openemr | |
outputStuff=$outputStuff$(wget -O buildLanguageDatabase.pl "http://openemr.git.sourceforge.net/git/gitweb.cgi?p=openemr/openemr;a=blob_plain;f=contrib/util/language_translations/buildLanguageDatabase.pl;hb=HEAD" 2>&1) | |
if [ ! -f buildLanguageDatabase.pl ]; then | |
#Unable to download file, so error out script | |
echo "Unable to connect to sourceforge, so quitting" | |
exit | |
fi | |
chmod +x buildLanguageDatabase.pl | |
# Get log from previous official build (used at end as sanity check) | |
outputStuff=$outputStuff$(wget -O log_buildLanguageDatabase.txt "http://openemr.git.sourceforge.net/git/gitweb.cgi?p=openemr/openemr;a=blob_plain;f=contrib/util/language_translations/log_buildLanguageDatabase.txt;hb=HEAD" 2>&1) | |
# Get most recent listing of offical constants | |
outputStuff=$outputStuff$(wget -O currentConstants.txt "http://openemr.git.sourceforge.net/git/gitweb.cgi?p=openemr/openemr;a=blob_plain;f=contrib/util/language_translations/currentConstants.txt;hb=HEAD" 2>&1) | |
# Build the translation tables | |
outputStuff=$outputStuff$(./buildLanguageDatabase.pl spreadsheet.tsv currentConstants.txt) | |
# Remove the deprecated translation spreadsheet | |
rm languageTranslations_latin1.sql | |
# Sanity check, which should not contain any ERRORS. | |
# (Errors are almost always secondary to translators mistakenly putting | |
# tab or carriage return characters in their translations and requires | |
# manual repair in the google doc spreadsheet) | |
outputStuff=$outputStuff$(echo "Performing a diff of the new log file with the previous log file") | |
checkDiff=$(diff log_buildLanguageDatabase.txt log.txt) | |
checkError=$(echo "$checkDiff" | grep "ERROR: ") | |
if [ -n "$checkError" ] ; then | |
# Post the errors | |
echo "$outputStuff" | |
echo "ERROR(s) in google docs spreadsheets:" | |
echo "ERROR(s) in google docs spreadsheets:" > /git/translations_development_openemr/failedLastLog | |
echo "$checkError" | |
echo "$checkError" >> /git/translations_development_openemr/failedLastLog | |
cd /git/translations_development_openemr | |
git commit -a -m "Routine Automated Development Translations Failed Update" | |
git push origin | |
cd /git/translations | |
else | |
# Update the tables | |
echo "Success:" | |
echo "Success:" > successLastLog | |
echo "$checkDiff" | |
echo "$checkDiff" >> successLastLog | |
cp * /git/translations_development_openemr | |
cd /git/translations_development_openemr | |
git commit -a -m "Routine Automated Development Translations Update" | |
git push origin | |
cd /git/translations | |
fi | |
# Clean up | |
cd /git | |
rm /git/translations/* | |
rmdir /git/translations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment