Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to extract string from all c files in a folder using gettext

I'm trying to localize a 'C' project but I have no idea how to extract Strings by xgettext . And project has so many C files so extracting one by one is not feasible. S is it possible to extract strings from all files once. or there is any other way?

Thanks in advance

like image 502
prasadmadanayake Avatar asked Nov 25 '25 20:11

prasadmadanayake


2 Answers

You can pipe all of your *.c files to the xgettext program using xargs assuming you're on Linux/Mac, e.g:

~$ find MyFolder -name "*.c \
   | xargs xgettext --keyword=_ --language=C --output=messages.pot -

Be sure to pass - as the last parameter so it reads all files from stdin. Also you'll want to replace my simple keyword=_ example with the correct C function names.

like image 95
Tim Avatar answered Nov 28 '25 16:11

Tim


From similar question in php, it is easy to know:

find . -iname "*.c" | xargs xgettext
like image 41
Kearney Avatar answered Nov 28 '25 15:11

Kearney