Skip to content
Browse files

Update the themestrings run.sh script to download the themes when gen…

…erating themestrings for translation.

For now it allows us to do translations in the same way as we used to do them, before the themes were removed from SVN/GIT.
  • Loading branch information...
1 parent e45da57 commit 5815fcb9d0242a6efcdcedb26be4cc453018916a @kenni kenni committed Feb 12, 2011
Showing with 121 additions and 65 deletions.
  1. +121 −65 themestringstool/run.sh
View
186 themestringstool/run.sh
@@ -1,26 +1,35 @@
#!/bin/bash
#
-# This script uses the themestringstool to automate the themestrings generation,
-# by redirecting themestrings from the plugins into the themestrings.h files of
-# the plugins, instead of simply putting all of them into the themestrings.h
-# file in mythfrontend.
+# This script uses the themestringstool to automate the generation of
+# themestrings.
#
-# The script also downloads the latest third party themes from mythtv.org and
-# extracts their descriptions for translation.
+# The themes are downloaded from the internet and the strings are extracted
+# from specific themes or from all of the available themes.
+#
+# Strings related to the frontend or the backend goes into the "mythtv"
+# translation. Strings related to a plugin goes into the respective plugin.
#
# It should be sufficient to run this script once without any arguments, to
# update all themestrings for mythfrontend and the plugins.
#
set -e
-TS=`pwd`/themestrings
-MYTHTHEMES=`ls ../myththemes/ --file-type |grep "/$"`
-MYTHTHEMES_CORE=`ls ../mythtv/themes/ --file-type |grep "/$"`
+TS=$(pwd)/themestrings
+DOWNLOAD_DIR="temp_download"
+MYTHTHEMES_CORE=$(ls ../mythtv/themes/ --file-type |grep "/$")
MYTHTHEMES_DL="http://themes.mythtv.org/themes/repository/trunk/themes.zip"
-XMLPLUGINS="browser-ui.xml gallery-ui.xml game-ui.xml music-ui.xml \
- mytharchive-ui.xml mythburn-ui.xml netvision-ui.xml \
- news-ui.xml video-ui.xml zoneminder-ui.xml weather-ui.xml"
+REAL_XMLPLUGINS="browser-ui.xml gallery-ui.xml game-ui.xml music-ui.xml \
+ mytharchive-ui.xml mythburn-ui.xml netvision-ui.xml \
+ news-ui.xml video-ui.xml zoneminder-ui.xml weather-ui.xml \
+ mythnative-ui.xml"
+
+BOGUS_XMLPLUGINS="dvd-ui.xml gallery2-ui.xml" # dvd-ui.xml (DVD ripper) needs
+ # to be in this list to be excluded from mythtv. It isn't used anymore,
+ # but some themes still contains it.
+ # gallery2-ui.xml is a bogus file in the blue-abstract theme.
+
+XMLPLUGINS="${REAL_XMLPLUGINS} ${BOGUS_XMLPLUGINS}"
if [ ! -e ${TS} ]; then
echo ""
@@ -29,92 +38,143 @@ if [ ! -e ${TS} ]; then
exit 1
fi
-if [ `id -u` -eq 0 ]; then
+if [ $(id -u) -eq 0 ]; then
echo ""
echo "ERROR: You need to run this script as a regular user, you\
cannot run it with root/sudo."
echo ""
exit 1
fi
+# Download overview of themes to extract their descriptions and URLs
+[ -d ${DOWNLOAD_DIR}/themes ] && rm -rf temp_download/themes/*
+[ -d ${DOWNLOAD_DIR}/trunk ] && rm -rf temp_download/trunk/*
+[ ! -d ${DOWNLOAD_DIR}/themes ] && mkdir -p temp_download/themes
+echo "Downloading list of themes.."
+wget -q ${MYTHTHEMES_DL} -O ${DOWNLOAD_DIR}/themes.zip
+echo "Extracting list of themes.."
+unzip -q -o ${DOWNLOAD_DIR}/themes.zip -d temp_download/
+
+# Download the themes
+echo ""
+echo "Downloading and extracting all available themes:"
+echo ""
+for i in $(ls ${DOWNLOAD_DIR}/trunk/); do
+ THEME_URL=$(cat ${DOWNLOAD_DIR}/trunk/${i}/themeinfo.xml |grep "</*url>"|sed -e "s/ *<\/*url>//g")
+ THEME_FILENAME=$(basename ${THEME_URL})
+ [ ! -f ${DOWNLOAD_DIR}/${THEME_FILENAME} ] && echo "Downloading theme ${THEME_FILENAME}.." && wget -q ${THEME_URL} -P temp_download/
+ echo "Extracting theme ${THEME_FILENAME}.."
+ unzip -q -o ${DOWNLOAD_DIR}/${THEME_FILENAME} -d temp_download/themes/
+done
+
+
+#####################################################################
+# #
+# Select the themes from which strings should be extracted #
+# #
+#####################################################################
+
+# Select the themes that should be translatable (theme name = directory name after extraction)
+TRANSLATABLE_THEMES="Arclight Childish Graphite metallurgy Mythbuntu MythCenter MythCenter-wide Terra"
+#TRANSLATABLE_THEMES=$(ls ${DOWNLOAD_DIR}/themes/ --file-type |grep "/$"|tr '/' ' ') #All themes
+
+#Remove the extracted themes which shouldn't be translatable
+echo ""
+echo "Strings will be extracted from the following themes:"
+echo ${TRANSLATABLE_THEMES} | tr ' ' '\n'
+shopt -s extglob
+rm -rf ${DOWNLOAD_DIR}/themes/!($(echo ${TRANSLATABLE_THEMES}|tr ' ' '|'))
+shopt -u extglob
+
+
+#####################################################################
+# #
+# Generate a themestrings.h file for mythtv #
+# #
+# Contains non-plugin related strings as well as theme descriptions #
+# #
+#####################################################################
+
# Exclude mythplugins directory and myththemes files related to plugins as
-# we don't want these strings added to mythfrontend.
-pushd ..
- chmod a-x mythplugins
- for I in ${MYTHTHEMES}; do
- for J in ${XMLPLUGINS}; do
- [ -e myththemes/${I}${J} ] && chmod a-r myththemes/${I}${J}
- done
+# we don't want these strings added to mythfrontend
+chmod a-x ../mythplugins
+for I in ${TRANSLATABLE_THEMES}; do
+ for J in ${XMLPLUGINS}; do
+ [ -e ${DOWNLOAD_DIR}/themes/${I}/${J} ] && chmod a-r temp_download/themes/${I}/${J}
done
-popd > /dev/null
+done
-# Also exclude the plugin-related theme files in the mythtv core themes.
-pushd ../mythtv/themes
+# Also exclude the plugin-related theme files in the mythtv core themes
+pushd ../mythtv/themes > /dev/null
for I in ${MYTHTHEMES_CORE}; do
for J in ${XMLPLUGINS}; do
[ -e ${I}${J} ] && chmod a-r ${I}${J}
done
done
popd > /dev/null
-# Download third party themes to extract their description
-mkdir temp_download
-wget ${MYTHTHEMES_DL} -O temp_download/themes.zip
-unzip temp_download/themes.zip -d temp_download/
-
-echo "-------------------------------------------------------------------------"
-echo "\"Can't open [plugin-specific xml-file]\" error messages are expected below"
-echo "-------------------------------------------------------------------------"
-pushd ../mythtv/themes
- $TS ../.. . > /dev/null
+# Generate themestrings.h file for mythtv
+pushd ../mythtv/themes > /dev/null
+ echo ""
+ echo "Generating themestrings.h file for mythtv.."
+ ${TS} ../.. . &> /dev/null
+ ls -l themestrings.h
+ echo "Number of strings: $(( $(cat themestrings.h|wc -l)-2 ))"
popd > /dev/null
-echo "-------------------------------------------------------------------------"
-echo "...until this point"
-echo "-------------------------------------------------------------------------"
-rm -rf temp_download
-
-# Restore file permissions
-pushd ..
- chmod a+x mythplugins
- for I in ${MYTHTHEMES}; do
- for J in ${XMLPLUGINS}; do
- [ -e myththemes/${I}${J} ] && chmod a+r myththemes/${I}${J}
- done
+# Restore directory permissions for mythplugins
+chmod a+x ../mythplugins
+for I in ${TRANSLATABLE_THEMES}; do
+ for J in ${XMLPLUGINS}; do
+ [ -e ${DOWNLOAD_DIR}/themes/${I}/${J} ] && chmod a+r temp_download/themes/${I}/${J}
done
-popd > /dev/null
+done
-pushd ../mythtv/themes
+# Restore file permissions for plugin-related theme files
+pushd ../mythtv/themes > /dev/null
for I in ${MYTHTHEMES_CORE}; do
for J in ${XMLPLUGINS}; do
[ -e ${I}${J} ] && chmod a+r ${I}${J}
done
done
popd > /dev/null
-# updateplugin plugindir [xml file] [xml file]
-function updateplugin {
- pushd ../mythplugins/$1
- mkdir temp_themestrings > /dev/null 2>&1
- COUNT=0
- [ -n "$2" ] && for i in `ls ../../myththemes/*/${2} ../../mythtv/themes/*/${2} 2>/dev/null`; do
- cp $i temp_themestrings/${COUNT}-${2}
- COUNT=$((COUNT+1))
- done
- [ -n "$3" ] && for i in `ls ../../myththemes/*/${3} ../../mythtv/themes/*/${3} 2>/dev/null`; do
- cp $i temp_themestrings/${COUNT}-${3}
- COUNT=$((COUNT+1))
+#####################################################################
+# #
+# Generate themestrings.h files for the plugins #
+# #
+# Contains plugin-related strings from core and downloadable themes #
+# #
+#####################################################################
+
+# updateplugin plugindir [xml files]
+function updateplugin {
+ ARGS=($@)
+ XML_FILES=${ARGS[@]:1}
+ pushd ../mythplugins/${1} > /dev/null
+ [ ! -d temp_themestrings ] && mkdir temp_themestrings &> /dev/null
+
+ for xmlfile in ${XML_FILES}; do
+ COUNT=0
+ [ -n "${xmlfile}" ] && for sourcefile in $(ls ../../themestringstool/${DOWNLOAD_DIR}/themes/*/${xmlfile} ../../mythtv/themes/*/${xmlfile} 2>/dev/null); do
+ cp ${sourcefile} temp_themestrings/${COUNT}-${xmlfile}
+ COUNT=$((COUNT+1))
+ done
done
- $TS . `pwd`/i18n > /dev/null
+ echo ""
+ echo "Generating themestrings.h file for ${1}.."
+ ${TS} . $(pwd)/i18n > /dev/null
+ ls -l i18n/themestrings.h
+ echo "Number of strings: $(( $(cat i18n/themestrings.h|wc -l)-2 ))"
rm -rf temp_themestrings
popd > /dev/null
}
-updateplugin mytharchive mytharchive-ui.xml mythburn-ui.xml
+updateplugin mytharchive mytharchive-ui.xml mythburn-ui.xml mythnative-ui.xml
updateplugin mythbrowser browser-ui.xml
updateplugin mythgallery gallery-ui.xml
updateplugin mythgame game-ui.xml
@@ -125,7 +185,3 @@ updateplugin mythvideo video-ui.xml
updateplugin mythweather weather-ui.xml
updateplugin mythzoneminder zoneminder-ui.xml
-pushd .. > /dev/null
- svn st
-# emacs `svn st | grep "^M" | sed -e "s/^M//"` &
-popd > /dev/null

0 comments on commit 5815fcb

Please sign in to comment.
Something went wrong with that request. Please try again.