Last active
November 27, 2020 08:11
-
-
Save jrenggli/b2d7b80ffdbcfb81c45753c86c58583c to your computer and use it in GitHub Desktop.
Update translation files for all TYPO3 extensions present in the filesystem. Ideally for continuous integration. No database required
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
#!/usr/bin/env bash | |
# Fetch translation files for all TYPO3 extensions present in the filesystem | |
# | |
# In contrast to the TYPO3 CLI command to retrieve translations, this script | |
# can be executed without having a DB connection available. This is useful to | |
# fetch all translations in the build step without any TYPO3 dependencies. | |
# | |
# Adjust the variables below if necessary | |
PATH_site="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/" | |
mirrorUrl='https://localize.typo3.org/xliff/' | |
transientRoot="${PATH_site}app/var/transient/" | |
l10nRoot="${PATH_site}app/var/labels/" | |
typo3MajorVersion="v10" | |
languages=( | |
'de' | |
) | |
################################################## | |
function fetch { | |
extensionKey=${1} | |
majorVersion=${2} | |
mkdir -p ${transientRoot} | |
for language in "${languages[@]}"; do | |
if [[ ${majorVersion} ]] | |
then | |
# Append major version as uri segment for sysexts | |
packageUrl="${mirrorUrl}${extensionKey:0:1}/${extensionKey:1:1}/${extensionKey}-l10n/${extensionKey}-l10n-${language}.${majorVersion}.zip" | |
else | |
packageUrl="${mirrorUrl}${extensionKey:0:1}/${extensionKey:1:1}/${extensionKey}-l10n/${extensionKey}-l10n-${language}.zip" | |
fi | |
echo "EXT:${extensionKey}: Fetching from ${packageUrl}" | |
absolutePathToZipFile="${transientRoot}${extensionKey}-l10n-${language}.zip" | |
absoluteLanguagePath="${l10nRoot}${language}/" | |
absoluteExtensionLanguagePath="${absoluteLanguagePath}${extensionKey}" | |
mkdir -p ${absoluteLanguagePath} | |
wget -q -N ${packageUrl} -O ${absolutePathToZipFile} || rm ${absolutePathToZipFile} | |
if [ -f ${absolutePathToZipFile} ]; then | |
if [ -e ${absoluteExtensionLanguagePath} ]; then | |
rm -rf ${absoluteExtensionLanguagePath} | |
fi | |
unzip -q ${absolutePathToZipFile} -d ${absoluteLanguagePath} | |
fi | |
done | |
} | |
find ${PATH_site}app/public/typo3/sysext/ -mindepth 1 -maxdepth 1 -type d | while read E; do | |
# sysext translation files are different based on TYPO3 major version | |
fetch `basename ${E}` ${typo3MajorVersion} | |
done | |
find ${PATH_site}app/public/typo3conf/ext/ -mindepth 1 -maxdepth 1 -type d | while read E; do | |
fetch `basename ${E}` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment