Commit 9d238790 authored by Xavier Perseguers's avatar Xavier Perseguers
Browse files

[TASK] Script to recover lost translations from system extensions

Change-Id: I716db5ce51f71fc42cb665b02926ac8196642c0e
Reviewed-on: http://review.typo3.org/41962

Reviewed-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
parent 5fda0292
#!/usr/bin/env bash
. /home/pootle/scripts/etc/pootle.conf
. /home/pootle/scripts/etc/functions
ORIGIN="pootle@178.79.185.68:/var/www/vhosts/pootle.typo3.org/pootle/po/TYPO3."
# Allow to abort whole script on Ctrl+C
trap "exit" INT
pushd ${POOTLE_PO} >/dev/null
PROJECTS=$(find . -maxdepth 1 -name TYPO3.core.\* -type d | cut -b3- | sort)
for PROJECT in ${PROJECTS}; do
pushd ${PROJECT} >/dev/null
echo "[INFO] Fixing ${PROJECT}"
echo "[INFO] ==================================="
MAPPING=${POOTLE_PO}/${PROJECT}/.typo3/TYPO3v6.filemapping
if [ ! -f "${MAPPING}" ]; then
echo "[WARNING] - Mapping not found"
continue
fi
LANGUAGES=$(find . -maxdepth 1 -type d | cut -b3- | grep -v templates | grep -v .typo3 | sort)
for LANGUAGE in ${LANGUAGES}; do
pushd ${LANGUAGE} >/dev/null
echo "[INFO] ${PROJECT} - ${LANGUAGE}"
FILES=$(find . -maxdepth 1 -name locallang.\*.xlf | cut -b3- | sort)
FILES=$(find . -name \*.xlf | cut -b3- | sort)
for FILE in ${FILES}; do
echo ${FILE} | egrep -q "^locallang\.[0-9]+\.xlf$"
LEGACY=$?
TARGETS=$(cat ${FILE} | grep "<target" | grep -v "<target/>")
if [ -z "${TARGETS}" ]; then
if [ ${LEGACY} -eq 0 ]; then
TARGET_FILE=$(grep ${FILE} ${MAPPING} | cut -d' ' -f2)
if [ -z "${TARGET_FILE}" ]; then
# File does not exist for current TYPO3 version
continue
fi
else
TARGET_FILE=${FILE}
fi
echo "[WARNING] - Missing translations for ${FILE}"
TMP_NAME="/tmp/$(basename ${TARGET_FILE})"
rm -f ${TMP_NAME}
scp -q ${ORIGIN}${PROJECT}/${LANGUAGE}/${TARGET_FILE} ${TMP_NAME} >/dev/null 2>&1
if [ $? -eq 0 ]; then
grep -q "<target" ${TMP_NAME}
if [ $? -ne 0 ]; then
echo "[WARNING] - Old server has no translations either (${TARGET_FILE})"
rm -f ${TMP_NAME}
continue
fi
mv ${TMP_NAME} ${FILE}
${POOTLE_MANAGE} update_stores --force --project=${PROJECT} --language=${LANGUAGE} >/dev/null 2>&1
fi
fi
done
popd >/dev/null
done
popd >/dev/null
done
popd >/dev/null
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment