localizationxgettext

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


Solution

  • 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.