Last active
September 25, 2015 05:07
-
-
Save bradymiller/867832 to your computer and use it in GitHub Desktop.
Script to routinely test the google docs openemr translations and update development translations if it passes testing.
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 | |
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) | |
# Get and set the building script from within openemr | |
outputStuff=$outputStuff$(wget -O buildLanguageDatabase.pl "http://sourceforge.net/p/openemr/code/ci/master/tree/contrib/util/language_translations/buildLanguageDatabase.pl?format=raw" 2>&1) | |
chmod +x buildLanguageDatabase.pl | |
# Get log from previous official build (used at end as sanity check) | |
outputStuff=$outputStuff$(wget -O log_buildLanguageDatabase.txt "http://sourceforge.net/p/openemr/code/ci/master/tree/contrib/util/language_translations/log_buildLanguageDatabase.txt?format=raw" 2>&1) | |
# Get most recent listing of offical constants | |
outputStuff=$outputStuff$(wget -O currentConstants.txt "http://sourceforge.net/p/openemr/code/ci/master/tree/contrib/util/language_translations/currentConstants.txt?format=raw" 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