Commit b6b0c8c4 authored by Dominique Feyer's avatar Dominique Feyer
Browse files

[TASK] Initial commit

Change-Id: Id0358b5f99327eaecdac2f6fe86faf3498e52735
parents
.build-language-pack-lastbuild
tmp/*
#!/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
_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
# Remove old temp directory
if [ "$_LANGUAGE_PACK_TEMP" != "" ] && [ -d $_LANGUAGE_PACK_TEMP ]; then
rm -Rf $_LANGUAGE_PACK_TEMP
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
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
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
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
# 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
fi
done
# Write XML resume file (used by TER to know the updated language pack)
done
# Restore IFS
IFS=$OLD_IFS
exit 0
#!/bin/bash
. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/pootle.conf
. /var/www/vhosts/pootle.typo3.org/home/scripts/etc/functions
for PROJECT in $(ls --ignore=po --ignore=terminology --ignore=tutorial $POOTLE_PO); do
pootle-create-project $PROJECT >/dev/null 2>/dev/null
if [ $? = 0 ]; then
echo
echo "Refresh project $PROJECT"
pootle-refresh-project $PROJECT
fi
done
#!/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
if [ "$PROJECT" = "" ]; then
echo
msg "Please provide a project name"
echo "Usage: pootle-create-project project-name"
echo
exit 1
fi
# Check if the project exist in the database
_PROJECT_COUNTER=$(mysqlpipe "SELECT id FROM pootle_app_project WHERE code = '${PROJECT}' LIMIT 1\g" | wc -l)
if [ "$_PROJECT_COUNTER" -gt 0 ]; then
echo
msg "the current project $PROJECT exist in the database, unable to add a new one with the same name"
echo
exit 1
fi
echo
echo "Create new project in the database ..."
# Create directory record
_DIRECTORY_COUNTER=$(mysqlpipe "SELECT id FROM pootle_app_directory WHERE pootle_path = '/projects/${PROJECT}/' LIMIT 1\g" | wc -l)
if [ "$_DIRECTORY_COUNTER" -gt 0 ]; then
echo
msg "the current directory /projects/${PROJECT}/ exist in the database, unable to add a new one with the same name"
echo
exit 1
fi
mysqlpipe "INSERT INTO pootle_app_directory (name, parent_id, pootle_path) VALUES ('${PROJECT}', 2, '/projects/${PROJECT}/')\g" || exit 1
# Get directory record id
_POOTLE_DIRECTORY_ID=$(mysqlpipe "SELECT id FROM pootle_app_directory WHERE pootle_path = '/projects/${PROJECT}/' LIMIT 1\g" | tail -n1 | cut -f1)
if [ "$_POOTLE_DIRECTORY_ID" = "" ]; then
echo
msg "Unable to create directory record"
echo
exit 1
fi
if [ ! -d $POOTLE_PO/$PROJECT ]; then
# Create the project directory
mkdir -p $POOTLE_PO/$PROJECT
fi
# Create project record
mysqlpipe "INSERT INTO pootle_app_project (code, fullname, description, checkstyle, localfiletype, treestyle, source_language_id, directory_id) VALUES ('$PROJECT', '$PROJECT', '', 'standard', 'xlf', 'auto', 2, $_POOTLE_DIRECTORY_ID)\g"
exit 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
python /var/www/vhosts/pootle.typo3.org/pootle/manage.py $@
#!/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
if [ ! -d $POOTLE_PO/$PROJECT ]; then
echo
msg "$PROJECT is not a valid projet"
echo
exit 1
fi
echo
echo -n "1/3 Update translation projects "
pootle-manage update_translation_projects --project=$PROJECT 2>/dev/null && echo "DONE" || exit 1
echo
echo -n "2/3 Update database from XLIFF file "
pootle-manage update_stores --project=$PROJECT 2>/dev/null && echo DONE || exit 1
echo
echo -n "3/3 Refresh statistics "
pootle-manage refresh_stats --project=$PROJECT 2>/dev/null && echo DONE || exit 1
#!/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
#!/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"
#!/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
#
# Log
# Usage: msg "message"
function msg() {
local MSG="$@"
logger -s -t POOTLE "$MSG"
}
# Usage: log_notice "message"
function log_notice() {
local MSG="$@"
logger -p local0.notice -t POOTLE "$MSG"
}
#
# MySQL
# Usage: mysqlpipe "sql-query"
function mysqlpipe() {
echo $@ | mysql pootle | sed '1d'
}
#
# XSLT
# Usage: llxml2xliff extension-key language-key sourcexliff targetxliff
function llxml2xliff() {
local EXTENSION=$1
local LANG=$2
local SOURCE=$3
local TARGET=$4
if [ "$EXTENSION" = "" ] || [ "$LANG" = "" ] || [ "$SOURCE" = "" ] || [ "$TARGET" = "" ]; then
echo
msg "Please provide source and target XLIFF. Unable to convert XLIFF to LLXML."
echo
exit 1
fi
xsltproc --stringparam source $SOURCE \
--stringparam lang $LANG \
--stringparam extension $EXTENSION \
--stringparam date "$(date -u)" \
$XSL_LLXML2XLIFF_TARGET $TARGET
}
#
# Pootle
# Usage: getProjectUpdatedSince 2011-07-14
function getProjectUpdatedSince() {
local SINCE=$1
local PROJECT_ONLY=$2
if [ "$SINCE" = "" ]; then
echo "Empty date, unable to select updated project"
exit 1
fi
if [ "$PROJECT_ONLY" = "" ]; then
mysqlpipe "SELECT p.id, p.code, 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
WHERE ( u.state = 50 OR u.state = 200 ) AND u.mtime > '$SINCE'
AND p.code != 'terminology' AND p.code != 'tutorial'
GROUP BY p.id
ORDER BY u.mtime DESC;"
else
mysqlpipe "SELECT p.id, p.code, 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
WHERE ( u.state = 50 OR u.state = 200 )
AND p.code = '$PROJECT_ONLY'
GROUP BY p.id
ORDER BY u.mtime DESC;"
fi
}
# Usage: getLanguageProjectUpdatedSince project-id 2011-07-14
function getLanguageProjectUpdatedSince() {
local PROJECT_ID=$1
if [ "$PROJECT_ID" = "" ]; then
echo "Empty project id, unable to select updated language project"
exit 1
fi
local SINCE=$2
if [ "$SINCE" = "" ]; then
echo "Empty date, unable to select updated language project"
exit 1
fi
mysqlpipe "SELECT tp.real_path, p.id, p.code, u.mtime, UNIX_TIMESTAMP(u.mtime) AS tstamp, l.code AS language
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
LEFT JOIN pootle_app_language AS l ON l.id = tp.language_id
WHERE ( u.state = 50 OR u.state = 200 ) AND u.mtime > '$SINCE' AND p.id = $PROJECT_ID
GROUP BY tp.id
ORDER BY u.mtime DESC;"
}
ar:ar
bs:ba
bg:bg
pt_BR:br
ca:ca
ch:ch
cs:cz
de:de
da:dk
eo:eo
es:es
et:et
eu:eu
fa:fa
fi:fi
fo:fo
fr:fr
gl:ga
ka:ge
kl:gl
el:gr
he:he
hi:hi
zh:hk
hr:hr
hu:hu
is:is
it:it
ja:jp
km:km
ko:kr
lt:lt
lv:lv
ms:my
nl:nl
no:no
pl:pl
pt:pt
fr_CA:qc
ro:ro
ru:ru
sv:se
sl:si
sk:sk
sr:sr
th:th
tr:tr
uk:ua
vi:vn
POOTLE_SCRIPT_HOME=/var/www/vhosts/pootle.typo3.org/home/scripts
POOTLE_PID=$POOTLE_SCRIPT_HOME/tmp/fcgi-t3-pootle.pid
POOTLE_FCGI_SOCK=/tmp/fcgi-t3-pootle.sock
POOTLE_LOG=/var/log/pootle/pootle.log
POOTLE_ERR=/var/log/pootle/pootle.err
POOTLE_PO=/var/www/vhosts/pootle.typo3.org/pootle/po/
CONF_LANG_COMPAT=$POOTLE_SCRIPT_HOME/etc/lang-compat.conf
XSL_LLXML2XLIFF_SOURCE=$POOTLE_SCRIPT_HOME/etc/xsl/xliff2llxml-source.xsl
XSL_LLXML2XLIFF_TARGET=$POOTLE_SCRIPT_HOME/etc/xsl/xliff2llxml-target.xsl
_LAST_BUILD_FILE="$POOTLE_SCRIPT_HOME/.build-language-pack-lastbuild"
TER_L10N_PATH=/var/www/vhosts/pootle.typo3.org/l10n_ter/
core:TYPO3.core
ext:TYPO3.ext
<?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='yes' />
<xsl:template match="/xliff">
<T3locallang>
<data type="array">
<languageKey index="{$lang}" type="array">
<xsl:apply-templates select="file/body" />
</languageKey>
</data>
</T3locallang>
</xsl:template>
<xsl:template match="trans-unit">
<xsl:variable name="index" select="@id"/>
<label index="{$index}"><xsl:value-of select="source" /></label>
</xsl:template>
</xsl:stylesheet>
<?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='yes' />
<xsl:template match="/xliff">
<T3locallangExt>
<data type="array">
<languageKey index="{$lang}" type="array">
<xsl:apply-templates select="file/body" />
</languageKey>
</data>
</T3locallangExt>
</xsl:template>
<xsl:template match="trans-unit">
<xsl:variable name="index" select="@id"/>
<label index="{$index}"><xsl:value-of select="target" /></label>
</xsl:template>
</xsl:stylesheet>
Supports Markdown
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