| 1 |
1 |
#!/bin/sh |
| 2 |
2 |
|
| 3 |
|
CURDIR=$(pwd)/po/ |
| 4 |
|
|
| 5 |
|
get_languages() { |
| 6 |
|
if [ "$generated" = yes ];then |
| 7 |
|
languages=$(cat po/LINGUAS) |
| 8 |
|
elif [ -n $language ];then |
| 9 |
|
languages=$language |
| 10 |
|
else |
| 11 |
|
languages=$(basename -s.po $CURDIR/*.po) |
| 12 |
|
fi |
|
3 |
build_creds () { |
|
4 |
for lang in $@; do |
|
5 |
translators=$(sed -n '/^msgid "translator-credits"/,/^$/ {s@^"[ ]*\(.\+\)[ ]\+https://launchpad.net/~\([^ \\"]\+\).*$@\t<listitem><para>\1 (\2)</para></listitem>@p;/^$/Q}' po/$lang.po | sort -u) |
|
6 |
if [ -z "$translators" ]; then |
|
7 |
translators='\t<listitem><para>Translator data could not be acquired, please see <ulink url="https://translations.launchpad.net/xubuntu-docs">Launchpad</ulink>.</para></listitem>' |
|
8 |
fi |
|
9 |
printf "<itemizedlist>\n%b\n</itemizedlist>\n" "$translators" > $lang/translators.xml |
|
10 |
done |
| 13 |
11 |
} |
| 14 |
12 |
|
| 15 |
|
build_creds() { |
| 16 |
|
#for lang in `basename -s.po *.po`;do ## Good for testing, uses all translations it can find. |
| 17 |
|
echo "<itemizedlist>" |
| 18 |
|
for lang in $languages;do |
| 19 |
|
mkdir -p $CURDIR/mo/$lang/LC_MESSAGES/ |
| 20 |
|
msgfmt -o $CURDIR/mo/$lang/LC_MESSAGES/xubuntu-docs.mo $CURDIR/$lang.po |
| 21 |
|
translators=$(TEXTDOMAINDIR=$CURDIR/mo/ LANGUAGE=$lang gettext -d xubuntu-docs -s 'translator-credits' | \ |
| 22 |
|
sed -e 's@^ @\t<listitem><para>@' -e '/launchpad.net/s@$@)</para></listitem>@' \ |
| 23 |
|
-e 's@https://launchpad.net/~@(@' -e /Launchpad\ Contributions/d -e /^translator-credits$/d | sort -u) |
| 24 |
|
done |
| 25 |
|
if [ "$translators" = "" ];then |
| 26 |
|
echo "<listitem><para>Unable to parse translator data or data unavailable, see <ulink url=\"https://translations.launchpad.net/xubuntu-docs/\">Launchpad</ulink></para></listitem>" |
| 27 |
|
else |
| 28 |
|
echo "$translators" |
| 29 |
|
fi |
| 30 |
|
echo "</itemizedlist>" |
| 31 |
|
rm -rf $CURDIR/mo/ |
|
13 |
build_creds_alt () { |
|
14 |
for lang in $@; do |
|
15 |
mkdir -p po/mo/$lang/LC_MESSAGES |
|
16 |
msgfmt -o po/mo/$lang/LC_MESSAGES/xubuntu-docs.mo po/$lang.po |
|
17 |
translators=$(TEXTDOMAINDIR=po/mo LANGUAGE=$lang gettext -d xubuntu-docs -s 'translator-credits' | \ |
|
18 |
sed -n 's@^[ ]*\(.\+\)[ ]\+https://launchpad.net/~\([^ ]\+\).*$@\t<listitem><para>\1 (\2)</para></listitem>@p' | sort -u) |
|
19 |
if [ -z "$translators" ]; then |
|
20 |
translators='\t<listitem><para>Translator data could not be acquired, please see <ulink url="https://translations.launchpad.net/xubuntu-docs">Launchpad</ulink>.</para></listitem>' |
|
21 |
fi |
|
22 |
printf "<itemizedlist>\n%b\n</itemizedlist>\n" "$translators" > $lang/translators.xml |
|
23 |
done |
|
24 |
rm -rf po/mo |
| 32 |
25 |
} |
| 33 |
26 |
|
| 34 |
|
grep_creds() { |
| 35 |
|
## Don't build, just grep. |
| 36 |
|
## This is incomplete and unused, potentially helpful later. |
| 37 |
|
for lang in $languages;do |
| 38 |
|
echo msggrep --msgid -F -e 'translator-credits' $lang.po |
|
27 |
while getopts ":gl:" opt; do |
|
28 |
case $opt in |
|
29 |
g) |
|
30 |
generated="yes";; |
|
31 |
l) |
|
32 |
language=$OPTARG;; |
|
33 |
esac |
| 39 |
34 |
done |
| 40 |
|
} |
| 41 |
35 |
|
| 42 |
|
while getopts ":gl:" Option |
| 43 |
|
do |
| 44 |
|
case ${Option} in |
| 45 |
|
g) generated=yes;; |
| 46 |
|
l) language=${OPTARG};; |
| 47 |
|
*) echo "Please specify an argument.";; |
| 48 |
|
esac |
| 49 |
|
done |
|
36 |
if [ "$generated" = "yes" ]; then |
|
37 |
if [ ! -f po/LINGUAS ]; then |
|
38 |
../scripts/translate.sh -u |
|
39 |
fi |
|
40 |
build_creds $(cat po/LINGUAS) |
|
41 |
elif [ -n "$language" ]; then |
|
42 |
build_creds $language |
|
43 |
else |
|
44 |
build_creds $(basename -s .po -a po/*.po) |
|
45 |
fi |
| 50 |
46 |
|
| 51 |
|
get_languages |
| 52 |
|
build_creds |