mirror of
https://github.com/Icinga/L10n.git
synced 2025-07-31 01:34:20 +02:00
bin/update: Also update .github/stats.json
This commit is contained in:
parent
8f9bd936c6
commit
9cdbfb18ed
42
bin/update
42
bin/update
@ -100,12 +100,54 @@ if [ $CHANGES -eq 0 ]; then
|
|||||||
echo "No new messages found.";
|
echo "No new messages found.";
|
||||||
git checkout icinga.pot;
|
git checkout icinga.pot;
|
||||||
else
|
else
|
||||||
|
STATS=""
|
||||||
|
|
||||||
# Update intermediate (in-progress) catalogs
|
# Update intermediate (in-progress) catalogs
|
||||||
LOCALES=$(find . -mindepth 1 -maxdepth 1 -type d -regextype grep -regex '\./[a-z]\{2\}_[A-Z]\{2\}' -printf "%P ")
|
LOCALES=$(find . -mindepth 1 -maxdepth 1 -type d -regextype grep -regex '\./[a-z]\{2\}_[A-Z]\{2\}' -printf "%P ")
|
||||||
for locale_name in $LOCALES; do
|
for locale_name in $LOCALES; do
|
||||||
msgmerge --update --backup=none --lang=$locale_name --sort-by-file $locale_name/LC_MESSAGES/icinga.po icinga.pot
|
msgmerge --update --backup=none --lang=$locale_name --sort-by-file $locale_name/LC_MESSAGES/icinga.po icinga.pot
|
||||||
|
|
||||||
|
STATS_OUT=$(LC_ALL=C msgfmt --statistics $locale_name/LC_MESSAGES/icinga.po 2>&1 >/dev/null)
|
||||||
|
if [ -f "messages.mo" ]; then
|
||||||
|
rm "messages.mo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Make this a function? (is also used in bin/validate)
|
||||||
|
TRANSLATED=0
|
||||||
|
UNTRANSLATED=0
|
||||||
|
FUZZY=0
|
||||||
|
|
||||||
|
RE="[0-9]+"
|
||||||
|
LAST_LINE=$(echo "$STATS_OUT" | tail -1)
|
||||||
|
for chars in $LAST_LINE; do
|
||||||
|
if [[ "$chars" =~ $RE ]] && [[ ${BASH_REMATCH[0]} ]]; then
|
||||||
|
LAST_CNT="${BASH_REMATCH[0]}"
|
||||||
|
else
|
||||||
|
case $chars in
|
||||||
|
"translated")
|
||||||
|
TRANSLATED=$LAST_CNT
|
||||||
|
;;
|
||||||
|
"fuzzy")
|
||||||
|
FUZZY=$LAST_CNT
|
||||||
|
;;
|
||||||
|
"untranslated")
|
||||||
|
UNTRANSLATED=$LAST_CNT
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PROGRESS=$(python -c "print (int(round(($TRANSLATED.0 / ($TRANSLATED + $UNTRANSLATED + $FUZZY)) * 100)))")
|
||||||
|
STATS+=" $locale_name:$PROGRESS%"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Update locale statistics
|
||||||
|
python -c "import json; \
|
||||||
|
print ( \
|
||||||
|
json.dumps({k: v for k, v in (kv for kv in (s.split(':') for s in '$STATS'.strip().split()))}) \
|
||||||
|
) \
|
||||||
|
" > ../.github/stats.json
|
||||||
|
|
||||||
echo "New messages found!";
|
echo "New messages found!";
|
||||||
# Working tree is left dirty as the following step creates a new pull request
|
# Working tree is left dirty as the following step creates a new pull request
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user