This is a work-in-progress Gettext message extractor written in Rust, with support for JavaScript, TypeScript, and JSX files. It is inspired by lukasgeiter/gettext-extractor.
You can use gettext-extractor
by either providing a configuration file or piping the content directly to the program.
Provide a configuration file as an argument:
gettext-extractor -c /path/to/config.json
Here's an example config.json
:
Click to see the example config.json
{
"functions": {
"gettext": {
"text": 0
},
"ngettext": {
"text": 0,
"plural": 1
},
"pgettext": {
"text": 1,
"context": 0
},
"npgettext": {
"context": 0,
"text": 1,
"plural": 2
}
},
"exclude": [
"!{node_modules}",
"!*{test}.{tsx,ts}"
],
"include": [
"src/**/*.{ts,tsx}"
],
"base": "/path/to/your-project"
}
Alternatively, you can pipe the content to the program:
./gettext-extractor -b /path/to/your-project/ -e "\!{node_modules}/" -e '!*{test,stories}.{tsx,ts}' -i "src/**/*.{ts,tsx}"
Feel free to use whichever method suits your needs best for extracting Gettext messages from your codebase.
Please note that this project is still a work in progress, and feedback or contributions are highly appreciated!