[TASK] Synchronize with production 64/29964/5
authorXavier Perseguers <xavier@typo3.org>
Fri, 9 May 2014 09:03:24 +0000 (11:03 +0200)
committerXavier Perseguers <xavier@typo3.org>
Fri, 9 May 2014 09:10:21 +0000 (11:10 +0200)
Change-Id: Ib081d24cece23001a5381de8fff609ceae23a314
Reviewed-on: https://review.typo3.org/29964
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
19 files changed:
bin/build-language-pack [changed mode: 0644->0755]
bin/pootle-batch-check-project [new file with mode: 0755]
bin/pootle-batch-import-projects [changed mode: 0644->0755]
bin/pootle-check-project [new file with mode: 0755]
bin/pootle-create-project [changed mode: 0644->0755]
bin/pootle-manage [changed mode: 0644->0755]
bin/pootle-notify-hassuggestion [new file with mode: 0755]
bin/pootle-refresh-project [changed mode: 0644->0755]
bin/pootle-restart [deleted file]
bin/pootle-snapshot [new file with mode: 0755]
bin/pootle-start [deleted file]
bin/pootle-stop [deleted file]
bin/pootle-upgrade-all-extensions [new file with mode: 0755]
bin/pootle-upgrade-extension [new file with mode: 0755]
bin/t3xutils.phar [new file with mode: 0755]
bin/update-typo3-core-template [new file with mode: 0755]
etc/functions
etc/pootle.conf
etc/xsl/llxml2template.xsl [new file with mode: 0644]

old mode 100644 (file)
new mode 100755 (executable)
index 89b66bc..eebcddc
 #!/bin/bash
 
-set -e
+BASE_DIR=/var/www/vhosts/pootle.typo3.org/pootle/po
+EXPORT_DIR=/var/www/vhosts/pootle.typo3.org/l10n_ter
+STATE_DIR=/var/www/vhosts/pootle.typo3.org/home/scripts/.build-language-pack-state
+POOTLE_CONFIG=/var/www/vhosts/pootle.typo3.org/pootle/localsettings.py
+
+# -- no need to modify anything below
+
+FORCE_EXTENSION=$1
+EXT_PREFIX=TYPO3.TYPO3
+EXTENSIONS=$(ls $BASE_DIR | grep $EXT_PREFIX | cut -b13-)
+DATABASE_NAME=$(grep ^DATABASE_NAME $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_USER=$(grep ^DATABASE_USER $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_PASSWORD=$(grep ^DATABASE_PASSWORD $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_HOST=$(grep ^DATABASE_HOST $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+
+if [ ! -z "$FORCE_EXTENSION" ]; then
+       EXTENSIONS=$FORCE_EXTENSION
+fi
 
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
 . /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
 
-_BUILD_PROJECT=$1
-
-function build_language_pack() {
-       local _LANGUAGE_PROJECT_LANG=$1
-       if [ "$_LANGUAGE_PROJECT_LANG" = "" ]; then
-               echo
-               msg "You must provide a valid language"
-               echo
-               exit 1
-       fi
-
-       log_notice "Start building Language pack for extension \"$_PROJECT_NAME\" in language \"${_LANGUAGE_PROJECT_LANG}\""
-
-       # Get Language pack configuration
-       _LANGUAGE_PACK_NAME=${_PROJECT_NAME}-l10n-${_LANGUAGE_PROJECT_LANG}
-       _LANGUAGE_PACK_ARCHIVE=${_LANGUAGE_PACK_NAME}.zip
-       if [ "$_LANGUAGE_PROJECT_LANG" != "gl" ]; then
-               _STANDARD_LANGUAGE_KEY=$(cat $CONF_LANG_COMPAT | grep :${_LANGUAGE_PROJECT_LANG}$ | cut -d: -f1)
-       fi
-       if [ "$_STANDARD_LANGUAGE_KEY" = "" ]; then
-               _REAL_LANGUAGE_KEY=${_LANGUAGE_PROJECT_LANG}
-       else
-               _REAL_LANGUAGE_KEY=${_STANDARD_LANGUAGE_KEY}
-       fi
-       _LANGUAGE_PACK_PO=${POOTLE_PO}${_PROJECT_NAME}/${_REAL_LANGUAGE_KEY}
-       _LANGUAGE_PACK_TEMP=/tmp/l10n_ter/${_LANGUAGE_PACK_NAME}
-
-       echo
-       echo -e "\tUpdate $_LANGUAGE_PROJECT_PATH ($_LANGUAGE_PROJECT_LANG) ..."
-
-       # Prepare Language Pack
-       if [ "$_LANGUAGE_PACK_PO" = "" ] || [ ! -d "$_LANGUAGE_PACK_PO" ]; then
-               echo
-               msg "Unable to build language pack for a non existing project, XLIFF directory is missing"
-               msg "Missing directory: $_LANGUAGE_PACK_PO"
-               echo
-               exit 1
-       fi
+# Usage: mysqlpipe "sql-query"
+function mysqlpipe() {
+       echo $@ | mysql -u $DATABASE_USER -p"$DATABASE_PASSWORD" -h $DATABASE_HOST $DATABASE_NAME | sed '1d'
+}
 
-       # Remove old temp directory
-       if [ "$_LANGUAGE_PACK_TEMP" != "" ] && [ -d $_LANGUAGE_PACK_TEMP ]; then
-               rm -Rf $_LANGUAGE_PACK_TEMP
+# Usage: lastedit "project" "language"
+function lastedit() {
+       local PROJECT="$1"
+       local LANGUAGE="$2"
+
+       # XP/19.06.2013: Using filesystem instead of database
+       #timestamp=$(mysqlpipe "SELECT p.id, p.code, l.code AS lang, u.mtime, UNIX_TIMESTAMP(u.mtime) AS tstamp
+       #       FROM pootle_app_project AS p
+       #       LEFT JOIN pootle_app_translationproject as tp ON p.id = tp.project_id
+       #       LEFT JOIN pootle_store_store AS s ON tp.id = s.translation_project_id
+       #       LEFT JOIN pootle_store_unit AS u ON s.id = u.store_id
+       #       INNER JOIN pootle_app_language l ON l.id = tp.language_id
+       #       WHERE ( u.state = 50 OR u.state = 200 )
+       #       AND p.code = '$PROJECT'
+       #       AND l.code = '$LANGUAGE'
+       #       GROUP BY p.id, l.code;" \
+       #| awk '{ print $6 }')
+
+       LANGUAGE_DIR=$BASE_DIR/$PROJECT/$LANGUAGE
+       if [ -d $LANGUAGE_DIR ]; then
+               timestamp=$(find $LANGUAGE_DIR -type f -printf '%T@ %p\n' \
+                       | grep -v "./.translation_index" \
+                       | sort -n \
+                       | tail -n 1 \
+                       | cut -f1 -d.
+               )
        fi
 
-       # Create new temp directory
-       mkdir -p $_LANGUAGE_PACK_TEMP
-
-       # Process XLIFF file
-       echo
-       echo -e "\t\tMove XLIFF file to the temporary language pack ..."
-       for _LANGUAGE_PACK_XLIFF in $(find $_LANGUAGE_PACK_PO -name \*.xlf); do
-               _LANGUAGE_PACK_XLIFF_TEMP=$(echo $_LANGUAGE_PACK_XLIFF | sed -e "s#${POOTLE_PO}##;s#${_PROJECT_NAME}/${_REAL_LANGUAGE_KEY}#${_PROJECT_NAME}#;s#/locallang#/${_LANGUAGE_PROJECT_LANG}.locallang#")
-               _XLIFF_FILE_SOURCE=$(echo $_LANGUAGE_PACK_XLIFF | sed -e "s#${POOTLE_PO}##")
-               _LANGUAGE_PACK_XLIFF_TEMP_DIRECTORY=${_LANGUAGE_PACK_TEMP}/$(echo $_LANGUAGE_PACK_XLIFF_TEMP | sed -e "s#$(basename $_LANGUAGE_PACK_XLIFF_TEMP)##")
-               mkdir -p $_LANGUAGE_PACK_XLIFF_TEMP_DIRECTORY
-               echo -e "\t\t$_XLIFF_FILE_SOURCE -> $_LANGUAGE_PACK_XLIFF_TEMP ($_LANGUAGE_PACK_XLIFF_TEMP_DIRECTORY)"
-               cp -f $_LANGUAGE_PACK_XLIFF ${_LANGUAGE_PACK_TEMP}/$_LANGUAGE_PACK_XLIFF_TEMP
-               
-               # Convert XLIFF to LLXML
-               _SOURCE_XLIFF_FILE=$(echo $_LANGUAGE_PACK_XLIFF | sed -e "s#/${_REAL_LANGUAGE_KEY}/#/en/#")
-               _LLXML_FILE=${_LANGUAGE_PACK_TEMP}/$(echo $_LANGUAGE_PACK_XLIFF_TEMP | sed s/\.xlf$/\.xml/)
-               if [ -f $_SOURCE_XLIFF_FILE ]; then
-                       rm -f $_LLXML_FILE
-                       llxml2xliff $_PROJECT_NAME \
-                               ${_LANGUAGE_PROJECT_LANG} \
-                               $_SOURCE_XLIFF_FILE \
-                               $_LANGUAGE_PACK_XLIFF > $_LLXML_FILE
-               else
-                       # Can't found XLIFF source file
-                       exit 21
-               fi
-       done
-
-
-       # ZIP Language Pack
-       _CURRENT_DIRECTORY=$(pwd)
-       cd $_LANGUAGE_PACK_TEMP
-       if [ "$_LANGUAGE_PACK_ARCHIVE" != "" ] && [ -d $_PROJECT_NAME ]; then
-               zip -9 -r $_LANGUAGE_PACK_ARCHIVE $_PROJECT_NAME >/dev/null || exit 1
-
-               # Store the language pack in the TER directory
-               rm -f ${_LANGUAGE_PACK_PATH}/${_LANGUAGE_PACK_ARCHIVE}
-               mv $_LANGUAGE_PACK_ARCHIVE $_LANGUAGE_PACK_PATH || exit 1
-
-               # Removing temp language pack directory
-               # rm -Rf $_PROJECT_NAME
+       if [ -z "$timestamp" ]; then
+               echo 0
        else
-               echo
-               msg "Empty variable, unable to create language pack archive"
-               echo "_LANGUAGE_PACK_ARCHIVE: $_LANGUAGE_PACK_ARCHIVE"
-               echo "_PROJECT_NAME: $_PROJECT_NAME"
-               echo
-               exit 1
+               echo $timestamp
        fi
-
-       # Log
-       log_notice "Language pack for extension \"$_PROJECT_NAME\" in language \"${_LANGUAGE_PROJECT_LANG}\" build with success"
-
-       cd $_CURRENT_DIRECTORY
 }
 
-# Store start time
-_LAST_BUILD_DATE=$(cat $_LAST_BUILD_FILE)
-if [ "$_BUILD_PROJECT" != "" ]; then
-       _LAST_BUILD_DATE="1970-01-01"
-fi
-
-if [ "$_LAST_BUILD_DATE" = "" ]; then
-       echo
-       msg "No last build date, something wrong"
-       echo
-       exit 1
+cd $(dirname $0)
+if [ -z "$FORCE_EXTENSION" ]; then
+       # Sync whole stores, --project seems not totally reliable
+       echo "Synchronizing all stores ... "
+       ./pootle-manage sync_stores 2>&1
 fi
-if [ "$_BUILD_PROJECT" = "" ]; then
-       rm -f $_LAST_BUILD_FILE
-       date +%Y-%m-%d > $_LAST_BUILD_FILE
-fi 
-
-echo
-echo "Build language pack for project updated since $_LAST_BUILD_DATE"
-
-# Get updated project
-_OLD_IFS=$IFS
-IFS=$'\n'
-
-for _PROJECT_ROW in $(getProjectUpdatedSince $_LAST_BUILD_DATE $_BUILD_PROJECT); do
-       _PROJECT_ID=$(echo $_PROJECT_ROW | cut -f1)
-       _PROJECT_NAME=$(echo $_PROJECT_ROW | cut -f2)
-       echo
-       echo "Building Language Pack \"${_PROJECT_NAME}\" (${_PROJECT_ID})"
-
-       # Sync filesystem
-       pootle-manage sync_stores --project=$_PROJECT_NAME >/dev/null 2>/dev/null || \
-               exit 1
-
-       # Create language pack directory
-       _LANGUAGE_PACK_PATH=${TER_L10N_PATH}${_PROJECT_NAME:0:1}/${_PROJECT_NAME:1:1}/${_PROJECT_NAME}-l10n
-       mkdir -p $_LANGUAGE_PACK_PATH
-
-       # Get updated language project
-       for _LANGUAGE_PROJECT_ROW in $(getLanguageProjectUpdatedSince $_PROJECT_ID $_LAST_BUILD_DATE); do
 
-               # Get Language project configuration
-               _LANGUAGE_PROJECT_PATH=$(echo $_LANGUAGE_PROJECT_ROW | cut -f1)
-               _LANGUAGE_PROJECT_LANG=$(echo $_LANGUAGE_PROJECT_ROW | cut -f6)
-
-               # Build main language pack
-               build_language_pack $_LANGUAGE_PROJECT_LANG
+for EXT in $EXTENSIONS; do
+       EXTNAME=$(echo $EXT | sed -r 's/^[^.]+\.//')
+       echo "Packaging $EXTNAME"
+       if [ ! -z "$FORCE_EXTENSION" ]; then
+               echo -n "   synchronizing store ... "
+               ./pootle-manage sync_stores --project=$EXT_PREFIX.$EXT >/dev/null 2>&1
+               echo "done."
+       fi
+       echo -n "   updating statistics ... "
+       ./pootle-manage refresh_stats --project="$EXT_PREFIX.$EXT" >/dev/null 2>&1
+       echo "done."
+       pushd $BASE_DIR/$EXT_PREFIX.$EXT >/dev/null
+       rm -rf $EXPORT_DIR/_$EXTNAME
 
-               # Check if we have change the language key for the current language
-               _OLD_LANGUAGE_KEY=$(cat $CONF_LANG_COMPAT | grep ^${_LANGUAGE_PROJECT_LANG}: | cut -d: -f2)
-               if [ "$_OLD_LANGUAGE_KEY" != "" ] && [ "$_OLD_LANGUAGE_KEY" != "_LANGUAGE_PROJECT_LANG" ]; then
-                       build_language_pack $_OLD_LANGUAGE_KEY
+       _LANGUAGE_PACK_PATH=${EXPORT_DIR}/${EXTNAME:0:1}/${EXTNAME:1:1}/${EXTNAME}-l10n
+       mkdir -p $_LANGUAGE_PACK_PATH
+       mkdir -p $STATE_DIR/$EXT_PREFIX.$EXT
+
+       LANGUAGES="$(ls | grep -v templates) ba br ch cz dk si se gr hk kr ua jp qc vn ge ga"
+       for LANG in $LANGUAGES; do
+               ORIG_LANG=$LANG
+               case "$LANG" in
+                       'ba')
+                               ORIG_LANG=bs ;;
+                       'br')
+                               ORIG_LANG=pt_BR ;;
+                       'ch')
+                               ORIG_LANG=zh_CN ;;
+                       'cz')
+                               ORIG_LANG=cs ;;
+                       'dk')
+                               ORIG_LANG=da ;;
+                       'si')
+                               ORIG_LANG=sl ;;
+                       'se')
+                               ORIG_LANG=sv ;;
+                       'gr')
+                               ORIG_LANG=el ;;
+                       'hk')
+                               ORIG_LANG=zh_HK ;;
+                       'kr')
+                               ORIG_LANG=ko ;;
+                       'ua')
+                               ORIG_LANG=uk ;;
+                       'jp')
+                               ORIG_LANG=ja ;;
+                       'qc')
+                               ORIG_LANG=fr_CA ;;
+                       'vn')
+                               ORIG_LANG=vi ;;
+                       'ge')
+                               ORIG_LANG=ka ;;
+                       'ga')
+                               ORIG_LANG=gl ;;
+               esac
+
+               echo -n "   processing $LANG ... "
+               #/home/pootle/scripts/pootle-manage sync_stores --project="$EXT_PREFIX.$EXT" --language=$ORIG_LANG >/dev/null 2>&1
+
+               # Compute current state
+               STATUS_FILE=$STATE_DIR/$EXT_PREFIX.$EXT/$LANG.time
+               if [[ -f $STATUS_FILE && -z "$FORCE_EXTENSION" ]]; then
+                       LAST_GENERATION=$(cat $STATE_DIR/$EXT_PREFIX.$EXT/$LANG.time)
+               else
+                       LAST_GENERATION=0
+               fi
+               LAST_EDIT=$(lastedit "$EXT_PREFIX.$EXT" $ORIG_LANG)
+               if [[ $LAST_EDIT -gt 0 && $LAST_EDIT -ne $LAST_GENERATION ]]; then
+                       mkdir -p $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME
+                       cp -r $ORIG_LANG/* $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME
+                       pushd $EXPORT_DIR/_$EXTNAME/$LANG/$EXTNAME >/dev/null
+                       for XLF in $(find . -type f); do
+                               DIR=$(dirname $XLF)
+                               FILE=$(basename $XLF)
+                               mv $XLF $DIR/$LANG.$FILE
+
+                               # Convert XLIFF to LLXML
+                               _SOURCE_XLIFF_FILE=$BASE_DIR/$EXT_PREFIX.$EXT/templates/$DIR/$FILE
+                               LLXML=$DIR/$LANG.$(echo $FILE | sed s/\.xlf$/\.xml/)
+                               llxml2xliff $EXTNAME \
+                                       $LANG \
+                                       $_SOURCE_XLIFF_FILE \
+                                       $DIR/$LANG.$FILE > $LLXML
+                       done
+                       find . -name \*.xlf -exec chmod 644 {} \;
+                       find . -name \*.xml -exec chmod 644 {} \;
+                       rm -f $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip
+                       # ../ to include $EXTNAME directory
+                       cd ../
+                       zip -9 $_LANGUAGE_PACK_PATH/$EXTNAME-l10n-$LANG.zip -r . >/dev/null
+
+                       popd >/dev/null
+
+                       # Save current state
+                       echo $LAST_EDIT > $STATUS_FILE
+                       echo "done."
+               else
+                       echo "skipped."
                fi
-
        done
 
-       # Write XML resume file (used by TER to know the updated language pack)
+       # Create language pack index
+       pushd $_LANGUAGE_PACK_PATH >/dev/null
+
+       _LANGUAGE_PACK_NAME=${EXTNAME}-l10n
+       _LANGUAGE_INDEX_FILE=${_LANGUAGE_PACK_NAME}.xml
+       rm -f $_LANGUAGE_INDEX_FILE
+        touch $_LANGUAGE_INDEX_FILE
+
+       echo -e "<?xml version=\"1.0\" standalone=\"yes\" ?>"                   >> $_LANGUAGE_INDEX_FILE
+       echo -e "<TERlanguagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t<meta>"                                                      >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t\t<timestamp>$(date +"%s")</timestamp>"                      >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t\t<date>$(date +"%F %T")</date>"                             >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t</meta>"                                                     >> $_LANGUAGE_INDEX_FILE
+       echo -e "\t<languagePackIndex>"                                         >> $_LANGUAGE_INDEX_FILE
+
+       for p in $(find . -name \*.zip | sort);
+       do
+               _LANGUAGE_KEY=$(echo $p | sed -r "s/.*${_LANGUAGE_PACK_NAME}-(.*)\.zip\$/\1/")
+               echo -e "\t\t<languagepack language=\"$_LANGUAGE_KEY\">"        >> $_LANGUAGE_INDEX_FILE
+               echo -e "\t\t\t<md5>$(md5sum $p | cut -d" " -f1)</md5>"         >> $_LANGUAGE_INDEX_FILE
+               echo -e "\t\t</languagepack>"                                   >> $_LANGUAGE_INDEX_FILE
+       done
 
-done
+       echo -e "\t</languagePackIndex>"                                        >> $_LANGUAGE_INDEX_FILE
+       echo -e "</TERlanguagePackIndex>"                                       >> $_LANGUAGE_INDEX_FILE
 
-# Restore IFS
-IFS=$OLD_IFS
+       popd >/dev/null
 
-exit 0
+       rm -rf $EXPORT_DIR/_$EXTNAME
+       popd >/dev/null
+done
diff --git a/bin/pootle-batch-check-project b/bin/pootle-batch-check-project
new file mode 100755 (executable)
index 0000000..5799acd
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -e
+
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
+
+for PROJECT in $(list_all_typo3_project); do
+       pootle-check-project $PROJECT
+done
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/bin/pootle-check-project b/bin/pootle-check-project
new file mode 100755 (executable)
index 0000000..e0117fa
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+set -e
+
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
+
+PROJECT=$1
+UPDATE_PROJECT=0
+if [ "$PROJECT" == "" ]; then
+       echo "Missing project name"
+       exit 1
+fi
+
+echo
+echo "Check project $PROJECT ..."
+
+PROJECT_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po/$PROJECT/"
+
+if [ ! -d $PROJECT_DIRECTORY ]; then
+       echo "Project not found"
+       exit 1
+fi
+
+#
+# Check missing template project
+if [ ! -d $PROJECT_DIRECTORY/templates ]; then
+       echo "[WARNING] Missing templates ..."
+       # TODO Generate template based on english
+else
+       echo "[INFO] Templates exist"
+       # TODO Check if new file exist in english or deleted file in english
+fi
+
+#
+# Create missing language
+check_available_languages $PROJECT
+
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/bin/pootle-notify-hassuggestion b/bin/pootle-notify-hassuggestion
new file mode 100755 (executable)
index 0000000..08cf0e7
--- /dev/null
@@ -0,0 +1,128 @@
+#!/bin/bash
+
+POOTLE_CONFIG=/var/www/vhosts/pootle.typo3.org/pootle/localsettings.py
+
+# -- no need to modify anything below
+
+set -o errtrace
+set -o nounset
+
+#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
+trap onexit 1 2 3 15
+
+#--- onexit() -----------------------------------------------------
+#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
+function onexit() {
+       local exit_status=${1:-$?}
+       if [ $exit_status -gt 0 ]; then
+               echo Exiting $0 with $exit_status
+       fi
+       exit $exit_status
+}
+
+DATABASE_NAME=$(grep ^DATABASE_NAME $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_USER=$(grep ^DATABASE_USER $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_PASSWORD=$(grep ^DATABASE_PASSWORD $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+DATABASE_HOST=$(grep ^DATABASE_HOST $POOTLE_CONFIG | sed -r "s/.* = '([^']+)'.*/\1/")
+
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
+
+# Usage: mysqlpipe "sql-query"
+function mysqlpipe() {
+       echo $@ | mysql -u $DATABASE_USER -p"$DATABASE_PASSWORD" -h $DATABASE_HOST $DATABASE_NAME | sed '1d'
+}
+
+SAVEIFS=$IFS
+
+ROWS=$(mysqlpipe "
+       SELECT l.fullname AS language, l.code AS language_code, l.directory_id AS language_directory_id,
+               p.fullname AS project, p.code AS project_code, p.directory_id AS project_directory_id,
+               COUNT(*) AS suggestions
+       FROM pootle_app_suggestion s
+               INNER JOIN pootle_app_translationproject tp ON tp.id=s.translation_project_id
+               INNER JOIN pootle_app_language l ON l.id=tp.language_id
+               INNER JOIN pootle_app_project p ON p.id=tp.project_id
+               INNER JOIN pootle_store_unit su ON su.id=s.unit
+       WHERE s.state='pending' AND p.id>2
+       GROUP BY s.translation_project_id
+       ORDER BY project, language
+")
+
+IFS=$(echo -en "\n\b")
+
+for ROW in $ROWS;
+do
+       LANGUAGE=$(echo $ROW | awk -F "\t" '{ print $1 }')
+       LANGUAGE_CODE=$(echo $ROW | awk -F "\t" '{ print $2 }')
+       LANGUAGE_DIR_ID=$(echo $ROW | awk -F "\t" '{ print $3 }')
+       PROJECT=$(echo $ROW | awk -F "\t" '{ print $4 }')
+       PROJECT_CODE=$(echo $ROW | awk -F "\t" '{ print $5 }')
+       PROJECT_DIR_ID=$(echo $ROW | awk -F "\t" '{ print $6 }')
+       SUGGESTIONS=$(echo $ROW | awk -F "\t" '{print $7 }')
+
+       echo "[INFO] Found suggestions for project $PROJECT ($PROJECT_CODE) in $LANGUAGE"
+
+       # Look for translators for current project (either project itself or corresponding language)
+       TRANSLATORS=$(mysqlpipe "
+               SELECT DISTINCT u.username, u.first_name, u.last_name, u.email
+               FROM pootle_app_permissionset_positive_permissions pspp
+                       INNER JOIN pootle_app_permissionset ps ON ps.id=pspp.permissionset_id
+                       INNER JOIN pootle_app_pootleprofile pp ON pp.id=ps.profile_id
+                       INNER JOIN auth_user u ON u.id=pp.user_id
+                       INNER JOIN pootle_app_directory d ON d.id=ps.directory_id
+                       INNER JOIN auth_permission p ON p.id=pspp.permission_id
+               WHERE p.codename IN ('administrate', 'translate', 'review') AND u.is_active=1 AND u.email<>''
+                       AND d.id IN ($PROJECT_DIR_ID, $LANGUAGE_DIR_ID)
+               ORDER BY last_name
+       ")
+
+       #if [ -z "$TRANSLATORS" ]; then
+       #       echo "[WARNING] No translators found, falling back to superusers"
+       #       TRANSLATORS=$(mysqlpipe "
+       #               SELECT username, first_name, last_name, email
+       #               FROM auth_user
+       #               WHERE is_active=1 AND is_superuser=1
+       #       ")
+       #fi
+
+       for TRANSLATOR in $TRANSLATORS;
+       do
+               USERNAME=$(echo $TRANSLATOR | awk -F "\t" '{ print $1 }')
+               FIRST_NAME=$(echo $TRANSLATOR | awk -F "\t" '{ print $2 }')
+               LAST_NAME=$(echo $TRANSLATOR | awk -F "\t" '{ print $3 }')
+               EMAIL=$(echo $TRANSLATOR | awk -F "\t" '{ print $4 }')
+
+               echo "[INFO]    - Notifying $USERNAME"
+
+               mail -a"From: TYPO3 Translation Server <no-reply@typo3.org>" \
+                       -s "TYPO3 Pootle: $PROJECT ($LANGUAGE)" \
+                       "$EMAIL" <<EOM
+Dear $FIRST_NAME $LAST_NAME ($USERNAME),
+
+There are currently $SUGGESTIONS suggestions pending for approval for project $PROJECT ($LANGUAGE),
+please review them on:
+
+http://translation.typo3.org/${LANGUAGE_CODE}/${PROJECT_CODE}/translate.html?matchnames=hassuggestion
+
+
+Thanks for contributing to open-source software,
+
+Pootle
+
+
+PS: This is a weekly automated message that you received since you are registered as a
+translator either for project "$PROJECT" or language "$LANGUAGE".
+
+-- 
+TYPO3 translation server (Pootle)
+http://translation.typo3.org/
+EOM
+       done
+
+       # wait a bit before handling next project/language pair
+       sleep 10
+done
+
+IFS=$SAVEIFS
+
+onexit
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/bin/pootle-restart b/bin/pootle-restart
deleted file mode 100644 (file)
index 5e98d59..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-set -e
-
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
-
-pootle-stop > /dev/null && msg "stop done ..." || exit 1
-sleep 2
-pootle-start > /dev/null && msg "start done ..." || exit 1
-
-
-exit 0
diff --git a/bin/pootle-snapshot b/bin/pootle-snapshot
new file mode 100755 (executable)
index 0000000..7b5c885
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+SNAPSHOT_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/archives/snapshot"
+
+DESTIONATION_DIRECTORY="$SNAPSHOT_DIRECTORY/$(date +%Y%m%d)"
+mkdir -p $DESTIONATION_DIRECTORY
+mysqldump -ac pootle | gzip > $DESTIONATION_DIRECTORY/pootle.sql.gz
+tar cfpz $DESTIONATION_DIRECTORY/po.tar.gz /var/www/vhosts/pootle.typo3.org/pootle/po
diff --git a/bin/pootle-start b/bin/pootle-start
deleted file mode 100644 (file)
index 989ca06..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/bash
-
-set -e
-
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
-
-pootle-manage runfcgi \
-       socket=$POOTLE_FCGI_SOCK \
-       pidfile=$POOTLE_PID \
-       method=threaded \
-       minspare=2 \
-       maxspare=12 \
-       umask=007 \
-       outlog=$POOTLE_LOG \
-       errlog=$POOTLE_ERR && \
-       msg "service started with success" || \
-       msg "unable to start service"
diff --git a/bin/pootle-stop b/bin/pootle-stop
deleted file mode 100644 (file)
index b14ef33..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-set -e
-
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
-. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
-
-if [ -f $POOTLE_PID ]; then
-       kill $(cat $POOTLE_PID)
-       rm $POOTLE_PID
-       sleep 2
-       echo
-       msg "service stopped"
-       echo
-       exit 0
-else
-       echo 
-       msg "FCGI daemon is not running ..."
-       echo
-       exit 1
-fi
diff --git a/bin/pootle-upgrade-all-extensions b/bin/pootle-upgrade-all-extensions
new file mode 100755 (executable)
index 0000000..361d107
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -o errtrace
+set -o nounset
+
+#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
+trap onexit 1 2 3 15
+
+#--- onexit() -----------------------------------------------------
+#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
+function onexit() {
+       local exit_status=${1:-$?}
+       if [ $exit_status -gt 0 ]; then
+               echo Exiting $0 with $exit_status
+       fi
+       exit $exit_status
+}
+
+BASE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po"
+
+echo "[INFO] Fetch and cache TER extension metadata"
+t3xutils.phar updateinfo >/dev/null
+
+cd $BASE_DIRECTORY
+PROJECTS=$(find . -maxdepth 1 -type d | egrep 'TYPO3\.TYPO3\.ext\.' | sort)
+
+for PROJECT in $PROJECTS;
+do
+       EXTENSION=$(echo $PROJECT | cut -b19-)
+
+       echo -n "[INFO] Looking for latest version of $EXTENSION on TER: "
+       LASTLINE=$(t3xutils.phar info $EXTENSION 2>/dev/null | grep -v "Available versions:" | tail -n 1)
+       if [ -z "$LASTLINE" ]; then
+               echo "n/a"
+               echo "[ERROR] Extension $EXTENSION does not exist on TER"
+       else
+               LASTVERSION=$(echo $LASTLINE | awk '{ print $1 }' | egrep '^[0-9.]+$')
+               if [ -n "$LASTVERSION" ]; then
+                       echo $LASTVERSION
+                       LOCALVERSION=""
+                       if [ -f $BASE_DIRECTORY/$PROJECT/.ter-version ]; then
+                               LOCALVERSION=$(cat $BASE_DIRECTORY/$PROJECT/.ter-version)
+                       fi
+                       if [ -z "$LOCALVERSION" ] || [ "$LOCALVERSION" != "$LASTVERSION" ]; then
+                               echo "[INFO] Updating extension $EXTENSION to version $LASTVERSION"
+                               pootle-upgrade-extension $EXTENSION $LASTVERSION
+                       fi
+               fi
+       fi
+done
+
+onexit
diff --git a/bin/pootle-upgrade-extension b/bin/pootle-upgrade-extension
new file mode 100755 (executable)
index 0000000..dfe5a07
--- /dev/null
@@ -0,0 +1,158 @@
+#!/bin/bash
+
+set -o errtrace
+set -o nounset
+
+#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
+trap onexit 1 2 3 15
+
+#--- onexit() -----------------------------------------------------
+#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
+function onexit() {
+       local exit_status=${1:-$?}
+       if [ $exit_status -gt 0 ]; then
+               echo Exiting $0 with $exit_status
+       fi
+       exit $exit_status
+}
+
+# --- check_available_languages() ---------------------------------
+# @param $1 string               Pootle Project Name
+function check_available_languages() {
+       local NEED_UPDATE=0
+       local PROJECT_NAME=$1
+        for LANGUAGE_KEY in $(ls /var/www/vhosts/pootle.typo3.org/home/templates); do
+               local LANGUAGE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po/$PROJECT_NAME/$LANGUAGE_KEY"
+                if [ "$PROJECT_NAME" != "" ] && [ -d /var/www/vhosts/pootle.typo3.org/pootle/po/$PROJECT_NAME ] && [ ! -d $LANGUAGE_DIRECTORY ]; then
+                        mkdir -p $LANGUAGE_DIRECTORY
+                        echo "[NOTICE] Add project language \"$LANGUAGE_KEY\""
+                       NEED_UPDATE=1
+                fi
+        done
+       if [ $NEED_UPDATE == 1 ]; then
+               echo "[NOTICE] Update translation project"
+               pootle-manage update_translation_projects --project=$1 1>/dev/null 2>/dev/null
+       fi
+}
+
+SAVEIFS=$IFS
+
+XSL_LLXML2TEMPLATE="/var/www/vhosts/pootle.typo3.org/home/scripts/etc/xsl/llxml2template.xsl"
+TEMP_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/tmp"
+
+EXTENSION=$1
+VERSION=$2
+
+PROJECT_NAME="TYPO3.TYPO3.ext.$EXTENSION"
+PROJECT_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po/$PROJECT_NAME"
+#
+# Check if the project exist
+if [ ! -d $PROJECT_DIRECTORY ]; then
+       echo
+       echo "[ERROR] Project $PROJECT_NAME doesn't exist in Pootle, please create it before using this script"
+       echo "[ERROR] Please create directory: $PROJECT_DIRECTORY"
+       onexit 1
+fi
+
+#
+# Check if the templates directory exist
+TEMPLATE_DIRECTORY="$PROJECT_DIRECTORY/templates"
+if [ ! -d $TEMPLATE_DIRECTORY ]; then
+        echo
+        echo "[INFO] Templates directory for project $PROJECT_NAME doesn't exist in Pootle"
+       echo "[NOTICE] Create the templates directory"
+       mkdir -p $TEMPLATE_DIRECTORY
+fi
+
+cd $TEMP_DIRECTORY >/dev/null
+
+echo "[INFO] Downloading $EXTENSION $VERSION from TER"
+
+EXTENSION_T3X=$(echo "${EXTENSION}_${VERSION}.t3x" | tr '[:upper:]' '[:lower:]')
+
+#
+# Download t3x
+rm -f $EXTENSION_T3X
+wget -q http://typo3.org/fileadmin/ter/${EXTENSION_T3X:0:1}/${EXTENSION_T3X:1:1}/$EXTENSION_T3X
+
+#
+# Extract t3x
+#extract-t3x $EXTENSION_T3X $EXTENSION > /dev/null
+t3xutils.phar extract $EXTENSION_T3X $EXTENSION >/dev/null
+
+IFS=$(echo -en "\n\b")
+
+#
+# Create directory structure for templates
+for FILE in $(find $EXTENSION/ -name \*.xml); do
+       grep "T3locallang" "$FILE" 1> /dev/null
+       if [ $? == 0 ]; then
+               mkdir -p $TEMP_DIRECTORY/TYPO3.TYPO3.ext.$(dirname $FILE);
+               cp $FILE $TEMP_DIRECTORY/TYPO3.TYPO3.ext.$FILE;
+       fi
+done
+for FILE in $(find $EXTENSION/ -name \*.xlf); do
+       # Count number of dots in filename to skip e.g., de.locallang.xlf
+       DOTS=$(echo -n $(basename $FILE) | sed 's/[^.]//g' | wc -c)
+       if [ $DOTS -eq 1 ]; then
+               mkdir -p $TEMP_DIRECTORY/TYPO3.TYPO3.ext.$(dirname $FILE);
+               cp $FILE $TEMP_DIRECTORY/TYPO3.TYPO3.ext.$FILE;
+       fi
+done
+
+cd $TEMP_DIRECTORY
+for FILE in $(find TYPO3.TYPO3.ext.$EXTENSION -name \*.xml); do
+       grep "T3locallang" "$FILE" 1> /dev/null
+       if [ $? == 0 ]; then
+               XLF_FILE=$(echo $FILE | sed s/.xml$/.xlf/)
+               if [ ! -f $XLF_FILE ]; then
+                       echo "[INFO] Convert LLXML to XLIFF for file $FILE"
+                       if [ ! -f $XLF_FILE ]; then
+                               xsltproc --stringparam lang en \
+                                       --stringparam extension $EXTENSION \
+                                       --stringparam date "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" $XSL_LLXML2TEMPLATE $FILE | \
+                                       xmlstarlet ed --insert "/xliff/file/body/trans-unit" --type attr -n xml:space -v preserve > $XLF_FILE
+                       fi
+               fi
+       fi
+       rm -f $FILE
+done
+
+#
+# Deploy new templates files
+echo "[INFO] Deploy new templates to $TEMPLATE_DIRECTORY"
+cd $TEMPLATE_DIRECTORY/../../ && \
+       tar cfzp $TEMP_DIRECTORY/backup/$PROJECT_NAME-$(date +%Y%m%d).tar.gz $PROJECT_NAME && \
+       cd - && \
+       rm -Rf $TEMPLATE_DIRECTORY && \
+       mkdir -p $TEMPLATE_DIRECTORY && \
+       cp -a $TEMP_DIRECTORY/$PROJECT_NAME/* $TEMPLATE_DIRECTORY || \
+               onexit 5
+
+#
+# Check project available language
+check_available_languages $PROJECT_NAME
+
+#
+# Update project from templates
+echo "[INFO] Update from templates"
+pootle-manage update_from_templates --project=$PROJECT_NAME 1>/dev/null 2>/dev/null
+
+echo "[INFO] Refresh statistics"
+pootle-manage refresh_stats --project=$PROJECT_NAME 1>/dev/null 2>/dev/null
+
+echo "[NOTICE] Register version $VERSION for EXT:$EXTENSION"
+echo -n $VERSION > $PROJECT_DIRECTORY/.ter-version
+
+#
+# Cleanup
+cd $TEMP_DIRECTORY
+rm -f $EXTENSION_T3X
+if [ -d $EXTENSION ]; then
+       rm -rf $EXTENSION
+       rm -rf TYPO3.TYPO3.ext.$EXTENSION
+fi
+
+IFS=$SAVEIFS
+
+onexit
diff --git a/bin/t3xutils.phar b/bin/t3xutils.phar
new file mode 100755 (executable)
index 0000000..e6b1b30
Binary files /dev/null and b/bin/t3xutils.phar differ
diff --git a/bin/update-typo3-core-template b/bin/update-typo3-core-template
new file mode 100755 (executable)
index 0000000..4194456
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+set -e
+
+GIT_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/git/Core"
+PO_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po"
+TEMPLATE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/templates"
+
+# Usage: project_exist project.name
+function project_exist() {
+       echo -n "Check if project exist: "
+       if [ "$1" != "" ] && [ -d $PO_DIRECTORY/$1 ]; then
+               echo "OK"
+               if [ ! -d $PO_DIRECTORY/$1/templates ]; then
+                       mkdir -p $PO_DIRECTORY/$1/templates
+                       echo "Check if the templates exist: CREATED"
+                       return 1
+               fi
+       else
+               echo "FAILED"
+               return 1
+       fi
+}
+
+# Usage: check_available_languages project.name
+function check_available_languages() {
+       for LANGUAGE_KEY in $(ls /var/www/vhosts/pootle.typo3.org/home/templates); do
+               if [ "$1" != "" ] && [ ! -d $PO_DIRECTORY/$1/$LANGUAGE_KEY ]; then
+                       mkdir -p $PO_DIRECTORY/$1/$LANGUAGE_KEY
+                       echo "[NOTICE] Create project language \"$LANGUAGE_KEY\""
+               fi
+       done
+}
+
+# Usage: sanitize_template_file /path/to/file.xlf
+function sanitize_template_file() {
+       if [ "$1" != "" ] && [ -f "$1" ]; then
+               xmlstarlet ed -d "/xliff/file[@xml:space]/@xml:space" $1 | \
+                       xmlstarlet ed -d "/xliff/file/body/trans-unit[@xml:space]/@xml:space" | \
+                       xmlstarlet ed --insert "/xliff/file/body/trans-unit" --type attr -n xml:space -v preserve | \
+                       xmlstarlet ed -d "/xliff/file/body/trans-unit/target" | \
+                       xmlstarlet ed -d "/xliff/file[@target-language]/@target-language" | \
+                       xmlstarlet ed -d "/xliff/file/body/trans-unit[@approved]/@approved" | \
+                       xmlstarlet ed -u "/xliff/file[@source-language]/@source-language" -v en
+       fi
+}
+
+# Usage: list_typo3_typo3_core_projects
+function list_typo3_typo3_core_projects() {
+       ls $PO_DIRECTORY | grep TYPO3.TYPO3.core
+}
+
+# Usage; check_typo3_typo3_core_projects_languages
+function check_typo3_typo3_core_projects_languages() {
+       echo
+       echo "Check available language ,,,"
+        for CORE_PROJECT in $(list_typo3_typo3_core_projects); do
+               check_available_languages $CORE_PROJECT
+        done
+}
+
+# Usage: update_typo3_typo3_core_projects
+function update_typo3_typo3_core_projects() {
+       echo
+       echo "Update TYPO3.TYPO3.core projects ..."
+       for CORE_PROJECT in $(list_typo3_typo3_core_projects); do
+               pootle-manage update_translation_projects --project=$CORE_PROJECT
+               pootle-manage update_from_templates --project=$CORE_PROJECT
+       done
+}
+
+function git_typo3_typo3_core_pull() {
+       echo
+       echo "TYPO3 Core GIT Pull"
+       cd $GIT_DIRECTORY
+       git pull
+       git submodule init
+       git submodule update
+}
+
+# GIT pull
+git_typo3_typo3_core_pull
+
+# Check project language configuration
+check_typo3_typo3_core_projects_languages
+
+echo
+echo "Update templates projects ..."
+for FILE in $(find $GIT_DIRECTORY/ -name *.xlf | grep sysext); do
+       RELATIVE_FILE_PATH=$(echo $FILE | sed s#$GIT_DIRECTORY/## | cut -d/ -f4-)
+       PROJECT=$(echo TYPO3.TYPO3.core.$(echo $FILE | sed s#$GIT_DIRECTORY/## | cut -d/ -f3))
+       echo "$PROJECT/$RELATIVE_FILE_PATH"
+
+       # Check project configuration
+       project_exist $PROJECT || exit 0
+
+       # Update project templates
+       if [ $? = 0 ]; then
+               # Check if directory exist
+               RELATIVE_FILE_DIRECTORY=$(dirname $PO_DIRECTORY/$PROJECT/templates/$RELATIVE_FILE_PATH);
+               if [ ! -d $RELATIVE_FILE_DIRECTORY ]; then
+                       echo "Create directory: $RELATIVE_FILE_DIRECTORY"
+                       mkdir -p $RELATIVE_FILE_DIRECTORY
+               fi
+
+               # Deploy file from GIT
+               sanitize_template_file $FILE > \
+                       $PO_DIRECTORY/$PROJECT/templates/$RELATIVE_FILE_PATH
+       fi
+done
+
+# Update all core project
+update_typo3_typo3_core_projects
+
+echo "====== UPDATE FINISHED ======"
index fe79644..6817ba6 100644 (file)
@@ -1,3 +1,6 @@
+
+. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
+
 #
 # Log
 
@@ -48,6 +51,29 @@ function llxml2xliff() {
 #
 # Pootle
 
+# Usage: list_all_typo3_project
+function list_all_typo3_project() {
+       ls $POOTLE_PO | grep ^TYPO3.TYPO3
+}
+
+# Usage: list_all_flow3_project
+function list_all_flow3_project() {
+        ls $POOTLE_PO | grep ^TYPO3.FLOW3
+}
+
+# Usage: check_available_languages project.name
+function check_available_languages() {
+        for LANGUAGE_KEY in $(ls /var/www/vhosts/pootle.typo3.org/home/templates); do
+                if [ "$1" != "" ] && [ ! -d $POOTLE_PO/$1/$LANGUAGE_KEY ]; then
+                        mkdir -p $POOTLE_PO/$1/$LANGUAGE_KEY
+                        echo "[NOTICE] Create project language \"$LANGUAGE_KEY\""
+                       pootle-manage update_translation_projects --project=$1 --language=$LANGUAGE_KEY
+                       pootle-manage update_from_templates --project=$1 --language=$LANGUAGE_KEY
+                       pootle-manage refresh_stats --project=$1 --language=$LANGUAGE_KEY
+                fi
+        done
+}
+
 # Usage: getProjectUpdatedSince 2011-07-14
 function getProjectUpdatedSince() {
         local SINCE=$1
@@ -103,3 +129,18 @@ function getLanguageProjectUpdatedSince() {
                 GROUP BY tp.id
                 ORDER BY u.mtime DESC;"
 }
+
+# Usage: validProjectName project.name
+function validProjectName() {
+       local PROJECT_NAME=$1
+       if [ "$PROJECT_NAME" == "" ]; then
+               echo "Missing project name"
+               exit 1
+       fi
+
+       if [ -d $POOTLE_PO/$PROJECT_NAME ]; then
+               return 0
+       else
+               exit 1
+       fi
+}
index 3ef1e92..88f2b63 100644 (file)
@@ -9,6 +9,8 @@ POOTLE_PO=/var/www/vhosts/pootle.typo3.org/pootle/po/
 
 CONF_LANG_COMPAT=$POOTLE_SCRIPT_HOME/etc/lang-compat.conf
 
+LOCAL_GIT_CLONE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/home/git"
+
 XSL_LLXML2XLIFF_SOURCE=$POOTLE_SCRIPT_HOME/etc/xsl/xliff2llxml-source.xsl
 XSL_LLXML2XLIFF_TARGET=$POOTLE_SCRIPT_HOME/etc/xsl/xliff2llxml-target.xsl
 
diff --git a/etc/xsl/llxml2template.xsl b/etc/xsl/llxml2template.xsl
new file mode 100644 (file)
index 0000000..dd27b43
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet
+       version="1.0"
+       xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
+
+       <xsl:output method='xml'
+               version='1.0'
+               encoding='UTF-8'
+               indent='no' />
+
+       <xsl:template match="/T3locallang">
+               <xliff version="1.0">
+                       <file source-language="EN" datatype="plaintext" original="messages" date="{$date}" product-name="{$extension}">
+                               <header/>
+                               <body>
+                                       <xsl:apply-templates select="data[@type='array']/languageKey[@index='default']/label" />
+                               </body>
+                       </file>
+               </xliff>
+       </xsl:template>
+
+       <xsl:template match="label">
+               <xsl:variable name="index" select="@index"/>
+               <trans-unit id="{@index}">
+                       <source><xsl:value-of select="." /></source>
+               </trans-unit>
+       </xsl:template>
+
+</xsl:stylesheet>