Decrease PO files for Doc team imports

Remove untranslated strings and location information from PO files. The
location information is still in the POT files as reference for easy
regeneration using "msgmerge POTFILE POFILE -o COMPLETEPOFILE".

Our tools handle the smaller PO files just fine.

Enable this for Documentation projects.

Also, quote file name arguments in cleanup_po_files.

Change-Id: I4649314f68332d9db46a10aac0d7550bddc46d0e
This commit is contained in:
Andreas Jaeger 2015-04-22 15:39:13 +02:00
parent fb04574fc0
commit 41fe0097a4
2 changed files with 19 additions and 3 deletions

@ -347,11 +347,11 @@ function cleanup_po_files {
for i in `find $project/locale -name *.po `; do
# Output goes to stderr, so redirect to stdout to catch it.
trans=`msgfmt --statistics -o /dev/null $i 2>&1`
trans=`msgfmt --statistics -o /dev/null "$i" 2>&1`
check="^0 translated messages"
if [[ $trans =~ $check ]] ; then
# Nothing is translated, remove the file.
git rm -f $i
git rm -f "$i"
else
if [[ $trans =~ " translated message" ]] ; then
trans_no=`echo $trans|sed -e 's/ translated message.*$//'`
@ -371,8 +371,21 @@ function cleanup_po_files {
# For now we delete files that suddenly are less than 20
# per cent translated.
if [[ "$ratio" -lt "20" ]] ; then
git rm -f $i
git rm -f "$i"
fi
fi
done
}
# Reduce size of po files. This reduces the amount of content imported
# and makes for fewer imports.
# This does not touch the pot files. This way we can reconstruct the po files
# using "msgmerge POTFILE POFILE -o COMPLETEPOFILE".
function compress_po_files {
local directory=$1
for i in `find $directory -name *.po `; do
msgattrib --translated --no-location "$i" --output="${i}.tmp"
mv "${i}.tmp" "$i"
done
}

@ -41,6 +41,9 @@ tx pull -a -f
# Use lower percentage here to update the existing files.
tx pull -f --minimum-perc=50
# Compress downloaded po files
compress_po_files "doc"
# Add imported upstream translations to git
for FILE in ${DocFolder}/*; do
DOCNAME=${FILE#${DocFolder}/}