links/intl/gen-intl
2021-08-28 18:37:32 +03:00

49 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
LC_ALL=C
export LC_ALL
echo
echo Generating language table.
mangle_unprintable_command="`./mangle-unprintable`"
languages=`cat index.txt|sed 's/
//g'`
if [ -n "$languages" ]; then
(
n=0
echo '/* Automatically generated by gen-intl */'
for i in $languages; do
printf $i" " 1>&2
if test `cat $i.lng|wc -l` != `cat english.lng|wc -l`; then
echo 1>&2
echo 1>&2
echo language $i is not synchronized 1>&2
exit
fi
echo
echo 'static_const struct translation translation_'$i' [] = {'
cat $i.lng | cut -d ',' -f 2- | eval "$mangle_unprintable_command" | sed -e 's/^/ {/' -e 's/,[ ]*$/ },/'
echo '};'
n=`expr $n + 1`
done
echo
echo 'static_const struct translation_desc translations [] = {'
for i in $languages; do
echo ' { translation_'$i' },'
done
echo '};'
echo
(
echo '/* Automatically generated by gen-intl */'
echo
echo '#define N_LANGUAGES '$n
echo
cat english.lng | grep '^T_' | (cat; echo T__N_TEXTS) | sed 's/,.*//' | nl -v0 | sed 's/^\([^T ]*\) *\(.*\)$/#define \2 \1/'
) | sed 's/
//g' > language.h
) | sed 's/
//g' > ../language.inc
if ! test -f language.h || cmp -s ../language.h language.h; then
rm -f language.h
else
mv language.h ..
fi
echo
echo Done.
fi
echo