diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-08-16 04:32:39 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-08-16 04:32:39 -0500 |
commit | 9a9db98089717990cd5e0eef529f6bb0819ebe46 (patch) | |
tree | a9afaabce984d5fe552fa8bf1a9405db9bdd2699 /po/updatepo.sh | |
parent | 69a2124e9a081518297951256eb5c8d72d93361f (diff) |
New upstream version 0.5.1+git20170815
Diffstat (limited to 'po/updatepo.sh')
-rw-r--r-- | po/updatepo.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/po/updatepo.sh b/po/updatepo.sh new file mode 100644 index 00000000..d5b0f9d6 --- /dev/null +++ b/po/updatepo.sh @@ -0,0 +1,52 @@ +#!bash + +GITVER=`git describe --always --dirty` +GITHASH=`git rev-parse HEAD` + +echo "Update gettext translation files." + +DER=`pwd` +if [ ! -e "updatepo.sh" ] +then + echo "Error: Run from po/, the location of hardinfo.pot and XX.po files." + exit 1 +fi + +MSGTOTALOLD=`msgattrib --untranslated hardinfo.pot | grep -E "^msgstr \"\"" | wc -l` +echo "hardinfo.pot has $MSGTOTALOLD strings" + +mv hardinfo.pot hardinfo.pot.old +echo "" > hardinfo.pot # empty existing file to join (-j) with +for d in hardinfo/ shell/ modules/ includes/; +do + # work from hardinfo root to get reasonable file reference comments + cd .. + echo -n `pwd`; echo "/$d ..." + find "$d" -type f -name "*.[hc]" -print | sort | xargs xgettext -j -d hardinfo -o "$DER/hardinfo.pot" -k_ -kN_ -kC_:1c,2 -kNC_:1c,2 -c/ --from-code=UTF-8 + cd "$DER" +done; + +MSGTOTAL=`msgattrib --untranslated hardinfo.pot | grep -E "^msgstr \"\"" | wc -l` +TDIFF=$(($MSGTOTAL - $MSGTOTALOLD)) +CHANGE="$TDIFF" +if [ $TDIFF -gt 0 ]; then CHANGE="+$TDIFF"; fi +if [ $TDIFF -eq 0 ]; then CHANGE="no change"; fi +echo "hardinfo.pot now has $MSGTOTAL strings ($CHANGE)" +echo "(as of $GITVER $GITHASH)" + +for f in *.po +do + cp "$f" "$f.old" + + msgmerge -q -N "$f" hardinfo.pot > tmp.po + + # set/reset the X-Poedit-Basepath header + grep -v '"X-Poedit-Basepath\:[^"]*"' tmp.po | sed 's:\("Language\:[^"]*"\):\1\n"X-Poedit-Basepath\: ../\\n":' >"$f" + + rm -f tmp.po + + # stats + UNMSG=`msgattrib --untranslated "$f" | grep -E "^msgstr \"\"" | wc -l` + DONE=" "; if [ $UNMSG -eq 0 ]; then DONE="x"; fi + echo "- [$DONE] $f : ($UNMSG / $MSGTOTAL remain untranslated)" +done |