Search code examples
javascriptgettextxgettext

How do I use xgettext to scan JS file


How do I use xgettext by invoking the xgettext program in Window 10?

I tried the following, and it didn't work.

xgettext --language=JavaScript --from-code=utf-8 --keyword=gettext --sort-output --join-existing --no-wrap -f videobanner.js -d snapmaker -o output.po

The videobanner.js file:

export default {
    bannerH1Text: gettext("Snapmaker 3-in-1 3D Printer"),
    bannerH1Text: gettext("Turn your desktop into a workshop."),
    bannerButText: ettext("Play Video"),
};

Command gives the error:

xgettext: error while opening "export default {" for reading: No such file or directory


Solution

  • -f, --files-from=FILE
    get list of input files from FILE

    If you use -f, that file is supposed to contain a list of file names that xgettext should work on. Instead of that, just pass your file as a plain argument:

    xgettext ... videobanners.js
    

    No -f!