lukasgeiter / gettext-extractor

A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
MIT License
98 stars 21 forks source link

no strings found on keybase/client project #50

Closed mathieujobin closed 3 years ago

mathieujobin commented 3 years ago

I'm trying to use your tool to extract all text strings from the Keybase client.

They have several files that match your supported extensions.

mathieu:keybase-client :-) (master) $ find shared/ -name "*.ts" | wc -l 
158
mathieu:keybase-client :-) (master) $ find shared/ -name "*.js" | wc -l 
29
mathieu:keybase-client :-) (master) $ find shared/ -name "*.jsx" | wc -l 
0
mathieu:keybase-client :-) (master) $ find shared/ -name "*.tsx" | wc -l 
1789
mathieu:keybase-client :-) (master) $ find shared/ -name "*.html" | wc -l 
0
mathieu:keybase-client :-) (master) $ 

but the extractor ran from REPL, could not find any...

here is the full output

mathieu:keybase-client :-) (master) $ node
Welcome to Node.js v12.21.0.
Type ".help" for more information.
> const { GettextExtractor, JsExtractors, HtmlExtractors } = require('gettext-extractor');
undefined
> 
> let extractor = new GettextExtractor();
undefined
> 
> extractor.createJsParser([
...         JsExtractors.callExpression('getText', { arguments: { text: 0, context: 1 } }),
...         JsExtractors.callExpression('getPlural', { arguments: { text: 1, textPlural: 2, context: 3 } })
...     ]).parseFilesGlob('./shared/**/*.@(ts|js|tsx|jsx)');
JsParser {
  builder: CatalogBuilder {
    stats: {
      numberOfMessages: 0,
      numberOfPluralMessages: 0,
      numberOfMessageUsages: 0,
      numberOfContexts: 0,
      numberOfParsedFiles: 1965,
      numberOfParsedFilesWithMessages: 0
    },
    contexts: {}
  },
  extractors: [ [Function], [Function] ],
  stats: {
    numberOfMessages: 0,
    numberOfPluralMessages: 0,
    numberOfMessageUsages: 0,
    numberOfContexts: 0,
    numberOfParsedFiles: 1965,
    numberOfParsedFilesWithMessages: 0
  }
}
> extractor.createHtmlParser([ HtmlExtractors.elementContent('translate, [translate]') ]).parseFilesGlob('./shared/**/*.html');
HtmlParser {
  builder: CatalogBuilder {
    stats: {
      numberOfMessages: 0,
      numberOfPluralMessages: 0,
      numberOfMessageUsages: 0,
      numberOfContexts: 0,
      numberOfParsedFiles: 1965,
      numberOfParsedFilesWithMessages: 0
    },
    contexts: {}
  },
  extractors: [ [Function] ],
  stats: {
    numberOfMessages: 0,
    numberOfPluralMessages: 0,
    numberOfMessageUsages: 0,
    numberOfContexts: 0,
    numberOfParsedFiles: 1965,
    numberOfParsedFilesWithMessages: 0
  }
}
> 
> extractor.savePotFile('./messages.pot');
undefined
> 
> extractor.printStats();

     0 messages extracted
  -----------------------------
     0 total usages
  1965 files (0 with messages)
     0 message contexts

undefined
> 

anything else that I can try? Thanks

mathieujobin commented 3 years ago

Ah, I think I get it ! the function call to GetText/translate needs to be put in place before, this isn't going to automagically update the code whereever there is a english string.

now I feel stupid, thank you