extract.sh (919B)
1 #!/bin/sh 2 # This file is in the public domain. 3 # It extracts translateable strings from the JSON file(s). 4 # 5 # The resulting 'extracted.h' file is only used by 6 # gettext, and not in the actual code. We still make 7 # sure it is legal C code. 8 9 BASEDIR=$(dirname $0) 10 11 if [ -z $1 ]; then 12 TGTDIR=$BASEDIR 13 else 14 TGTDIR=$1 15 fi 16 17 for n in ${BASEDIR}/redux.??.json 18 do 19 jq '.required_attributes[].label' < $n | awk '{print "_(" $0 "),"}' >> ${TGTDIR}/prep.h 20 done 21 22 jq '.countries[].continent' < ${BASEDIR}/redux.countries.json | awk '{print "_(" $0 "),"}' >> ${TGTDIR}/prep.h 23 24 jq '.countries[].name' < ${BASEDIR}/redux.countries.json | awk '{print "_(" $0 "),"}' >> ${TGTDIR}/prep.h 25 26 echo "// This is a generated file, see extract.sh" > ${TGTDIR}/extracted.h 27 echo "const char * i18n[] = {" >> ${TGTDIR}/extracted.h 28 sort ${TGTDIR}/prep.h | uniq >> ${TGTDIR}/extracted.h 29 echo "};" >> ${TGTDIR}/extracted.h 30 31 rm -f ${TGTDIR}/prep.h