From kde-devel Mon Mar 27 14:19:21 2006 From: Jason Harris Date: Mon, 27 Mar 2006 14:19:21 +0000 To: kde-devel Subject: shell scripting in CMakeLists.txt? Message-Id: <4427F469.8020300 () 30doradus ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=114346923526065 Hello, In my Makefile.am, I have some scripting to extract strings from my data files into a dummy source code file (kstars_i18n.cpp), just so the data file strings get placed in the translation database (kstars.pot). Without this scripting, strings in our data files won't be translated. How can I duplicate this functionality in the CMakeLists.txt file? At the moment, it appears to simply omit the strings extraction. thanks, Jason Here are the relevant lines from my Makefile.am: stringsfile: cd $(srcdir); rm -f kstars_i18n.cpp; rm -f cities.tmp; rm -f regions.tmp; rm -f countries.tmp; echo "#if 0" >> kstars_i18n.cpp; # extract constellations sed -e "s/\([0-9].*[a-z]\)//" < data/cnames.dat | sed 's/^[A-B]//' | \ sed 's/\([A-Z].*\)/i18n("Constellation name (optional)", "\1");/' | sed\ 's/\ "/"/g' >> "kstars_i18n.cpp"; # extract cities awk 'BEGIN {FS=":"}; {print "\"" $$1 "\""; }' < data/Cities.dat | \ sed 's/ *\"$$/\");/g' | sed 's/^\" */i18n(\"City name (optional, probab\ ly does not need a translation)\",\"/g' | sed 's/i18n(.*,"");//' >> "cities.tmp\ "; sort cities.tmp | uniq >> kstars_i18n.cpp; # extract regions awk 'BEGIN {FS=":"}; {print "\"" $$2 "\""; }' < data/Cities.dat | \ sed 's/ *\"$$/\");/g' | sed 's/^\" */i18n(\"Region\/state name (optiona\ l, rarely needs a translation)\",\"/g' | sed 's/i18n(.*,"");//' >> "regions.tmp\ "; sort regions.tmp | uniq >> kstars_i18n.cpp; # extract countries awk 'BEGIN {FS=":"}; {print "\"" $$3 "\""; }' < data/Cities.dat | \ sed 's/ *\"$$/\");/g' | sed 's/^\" */i18n(\"Country name (optional, but\ should be translated)\",\"/g' | sed 's/i18n(.*,"");//' >> "countries.tmp"; sort countries.tmp | uniq >> kstars_i18n.cpp; # extract image/info menu items awk 'BEGIN {FS=":"}; {print "i18n(\"Image/info menu item (should be tra\ nslated)\",\"" $$2 "\");"; }' < data/image_url.dat | \ sed 's/i18n(.*,"");//' >> "image_url.tmp"; sort image_url.tmp | uniq >> kstars_i18n.cpp; awk 'BEGIN {FS=":"}; {print "i18n(\"Image/info menu item (should be tra\ nslated)\",\"" $$2 "\");"; }' < data/info_url.dat | \ sed 's/i18n(.*,"");//' >> "info_url.tmp"; sort info_url.tmp | uniq >> kstars_i18n.cpp; # star names : some might be different in other languages, or they might have t\ o be adapted to non-Latin alphabets cat data/hip*.dat | perl -e 'while ( $$line= ) { $$starname = su\ bstr ($$line,72); chop $$starname; if ( $$starname =~ /(.*)\:/ ) { $$starnam\ e = $$1 . " "; } if ( $$starname =~ /(.*\w)(\s+)/) { $$starname = $$1; \ $$starnames{$$starname} = 1; } } foreach $$star( sort keys %starnames) { p\ rintf "i18n(\"star name\",\"%s\");\n", $$star; }' >> kstars_i18n.cpp; # extract deep-sky object names (sorry, I don't know perl-fu ;( ...using AWK ) cat data/ngcic*.dat | gawk '{ split(substr( $$0, 77 ), name, " "); \ if ( name[1]!="" ) { \ printf( "%s", name[1] ); i=2; \ while( name[i]!="" ) { printf( " %s", name[i] ); i++; } \ printf( "\n" ); } }' | uniq | sort | gawk '{ \ printf( "i18n(\"object name (optional)\", \"%s\");\n", $$0 ); }' >> kst\ ars_i18n.cpp # extract strings from file containing advanced URLs: cat data/advinterface.dat | gawk '( match( $$0, "KSLABEL" ) ) { \ name=substr($$0,10); \ printf( "i18n(\"Advanced URLs: description or category\", \"%s\")\n", n\ ame ); }' >> kstars_i18n.cpp # finish file echo "#endif" >> kstars_i18n.cpp; # cleanup temporary files rm -f cities.tmp; rm -f regions.tmp; rm -f countries.tmp; rm -f image_url.tmp; rm -f info_url.tmp; messages: rc.cpp stringsfile rm -f tips.cpp $(EXTRACTRC) *.ui tools/*.ui *.rc >> rc.cpp (cd data && $(PREPARETIPS) > ../tips.cpp) $(XGETTEXT) *.cpp *.h tools/*.cpp tools/*.h -o $(podir)/kstars.pot; rm -f tips.cpp rm -f kstars_i18n.cpp >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<