Permalink
Browse files

Generate a better translations index file with hashes and stats

  • Loading branch information...
peterix committed Dec 17, 2018
1 parent 74daeb8 commit fce9b89038906ce995127962be023a7021ebc60c
Showing with 26 additions and 15 deletions.
  1. +2 −1 es.po
  2. +0 −1 pt_BR.po
  3. +24 −13 release.sh
3 es.po
@@ -348,7 +348,8 @@ msgctxt "CheckJava|"
msgid ""
"Java is version %1, using %2-bit architecture.\n"
"\n"
msgstr "Versión de java %1, usaldo arquitectura de %2 bits"
msgstr "Versión de java %1, usaldo arquitectura de %2 bits.\n"
"\n"

#: src/api/logic/java/launch/CheckJava.cpp:127
msgctxt "CheckJava|"
@@ -1087,7 +1087,6 @@ msgid "Zip (*.zip)"
msgstr "Arquivo Zip (*.zip)"

#: src/api/logic/meta/Index.cpp:71
#, fuzzy
msgctxt "Index|"
msgid "Name"
msgstr "Nome"
@@ -1,6 +1,7 @@
#!/bin/sh

set -e
set -o pipefail

ROOT=$PWD
OUTPUT=$ROOT/build
@@ -11,7 +12,7 @@ LUPDATE_BIN=${LUPDATE_BIN:-lupdate-qt5}

if [ ! -d $OUTPUT ]
then
mkdir $OUTPUT
mkdir $OUTPUT
fi

echo "Cleaning old .qm files..."
@@ -20,23 +21,33 @@ rm -f $OUTPUT/*
echo "Creating .qm files..."
for po_file in $(ls *.po)
do
echo "Considering ${po_file}"
if cat "${po_file}" | grep '\"X-Qt-Contexts: true\\n\"' > /dev/null ; then
echo "Considering ${po_file}"
if cat "${po_file}" | grep '\"X-Qt-Contexts: true\\n\"' > /dev/null ; then
echo "Translation ${po_file} is OK"
else
else
echo "Translation ${po_file} is bad (missing X-Qt-Contexts)"
exit 1
fi
# gets everything up to the first dot
lang=$(echo $po_file | grep -oP "^[^\.]*")
echo " Converting $po_file to $lang.ts"
$LCONVERT_BIN -locations relative $po_file -o $lang.ts
echo " Create $lang.qm"
$LRELEASE_BIN $lang.ts -qm $OUTPUT/$lang.qm
fi

# gets everything up to the first dot
lang=$(echo $po_file | grep -oP "^[^\.]*")
echo " Converting $po_file to $lang.ts"
$LCONVERT_BIN -locations relative $po_file -o $lang.ts
echo " Create $lang.qm"
$LRELEASE_BIN $lang.ts -qm $OUTPUT/$lang.qm

# Create an index file with info about the amount of strings translated and expected hashes of the files (for local caching purposes)
PO_STATS=`msgfmt --statistics --output=/dev/null ${po_file} 2>&1`
UNTRANSLATED=`echo "$PO_STATS" | grep -o '[0-9]\+ untranslated messages\?' | sed 's/[a-z ]//g'` || UNTRANSLATED=0
FUZZY=`echo "$PO_STATS" | grep -o '[0-9]\+ fuzzy translations\?' | sed 's/[a-z ]//g'` || FUZZY=0
TRANSLATED=`echo "$PO_STATS" | grep -o '[0-9]\+ translated messages\?' | sed 's/[a-z ]//g'` || TRANSLATED=0
SHA1=`sha1sum $OUTPUT/$lang.qm | awk '{ print $1 }'`
echo "$lang.qm,$SHA1,$TRANSLATED,$FUZZY,$UNTRANSLATED" >> $OUTPUT/index_v2

# Create an index file with just the files (legacy)
echo "$lang.qm" >> $OUTPUT/index
done

ls $OUTPUT/ | grep -v index > $OUTPUT/index

echo "Removing intermediate files..."
rm *.ts

0 comments on commit fce9b89

Please sign in to comment.