forked from oe-alliance/oe-alliance-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateallpo.sh
executable file
·55 lines (54 loc) · 2.03 KB
/
updateallpo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Script to generate po files outside of the normal build process
#
# Pre-requisite:
# The following tools must be installed on your system and accessible from path
# gawk, find, xgettext, gsed, python, msguniq, msgmerge, msgattrib, msgfmt, msginit
#
# Run this script from the top folder of enigma2-plugins
#
#
# Author: Pr2 for OE-Alliance
# Version: 1.1
rootpath=$PWD
#
# Parsing the folders tree
#
printf "Po files update/creation from script starting.\n"
for directory in */po/ ; do
cd $rootpath/$directory
languages=($(ls *.po | tr "\n" " " | gsed 's/.po//g'))
plugin=$(gawk ' BEGIN { FS=" " } /^PLUGIN/ { print $3 }' Makefile.am)
printf "Processing plugin %s\n" $plugin
#
printf "Creating temporary file $plugin-py.pot\n"
find -s -X .. -name "*.py" -exec xgettext --no-wrap -L Python --from-code=UTF-8 -kpgettext:1c,2 --add-comments="TRANSLATORS:" -d $plugin -s -o $plugin-py.pot {} \+
gsed --in-place $plugin-py.pot --expression=s/CHARSET/UTF-8/
printf "Creating temporary file $plugin-xml.pot\n"
find -s -X .. -name "*.xml" -exec python $rootpath/xml2po.py {} \+ > $plugin-xml.pot
printf "Merging pot files to create: %s.pot\n" $plugin
cat $plugin-py.pot $plugin-xml.pot | msguniq --no-wrap --no-location -o $plugin.pot -
rm $plugin-py.pot $plugin-xml.pot
# git add $plugin.pot
OLDIFS=$IFS
IFS=" "
for lang in "${languages[@]}" ; do
if [ -f $lang.po ]; then
printf "Updating existing translation file $lang.po\n"
msgmerge --backup=none --no-wrap --no-location -s -U $lang.po $plugin.pot && touch $lang.po
msgattrib --no-wrap --no-obsolete $lang.po -o $lang.po
msgfmt -o $lang.mo $lang.po
# git add -f $lang.po; \
else \
printf "New file created: $lang.po, please add it to # github before commit\n"
msginit -l $lang.po -o $lang.po -i $plugin.pot --no-translator
msgfmt -o $lang.mo $lang.po
# git add -f $lang.po; \
fi
done
IFS=$OLDIFS
# git commit -m "Plugin $plugin po files updated at $(date +"%Y-%m-%d %H:%M")"
done
# git push
cd $rootpath/
printf "Po files update/creation from script finished!\n"