2
0

extract-translatable-strings.js 692 B

12345678910111213141516171819202122232425262728293031
  1. const { GettextExtractor, JsExtractors } = require('gettext-extractor');
  2. const extractor = new GettextExtractor();
  3. extractor
  4. .createJsParser([
  5. JsExtractors.callExpression('gettext', {
  6. arguments: {
  7. text: 0,
  8. context: 1,
  9. },
  10. }),
  11. JsExtractors.callExpression('gettext_noop', {
  12. arguments: {
  13. text: 0,
  14. context: 1,
  15. },
  16. }),
  17. JsExtractors.callExpression('ngettext', {
  18. arguments: {
  19. text: 0,
  20. textPlural: 1,
  21. context: 3,
  22. },
  23. }),
  24. ])
  25. .parseFilesGlob('./src/**/!(*.test).@(ts|js|tsx)');
  26. extractor.savePotFile('../wagtail/admin/locale/en/LC_MESSAGES/djangojs.po');
  27. extractor.printStats();