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 56 57 58 59 60 61 62 63 64 65
|
#!/bin/sh
#
# Messy script to convert all of the given .po files to a single C file on
# stdout.
cat <<EOF
/*
* Translation table - automatically generated by po2table.sh.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
struct msgtable_s {
char *msgid;
char *msgstr;
};
struct msgtable_s *minigettext__gettable(char *lang)
{
if (lang == 0)
return 0;
EOF
for POFILE; do
LANG=`basename "$POFILE" | sed 's/.po$//'`
echo " if (strncmp(lang, \"$LANG\", 2) == 0) {"
echo " static struct msgtable_s data[] = {";
awk 'BEGIN{i=0;s=0;}
/^msgid[ ]+/ {
if (s) print " }, ";
print " {";
print " " substr($0,7);
i=1;
s=0;
}
/^msgstr[ ]+/ {
print " ,";
i=0;s=1;
print " " substr($0,8);
}
/^[ ]*"/ {
if (i||s) print " " $0;
}
END {if (i||s) print " }\n";}
' < "$POFILE"
echo ' , { 0, 0 } };'
echo " return data;"
echo " }"
done
cat <<EOF
return 0;
}
/* EOF */
EOF
# EOF
|