gettext-extractor icon indicating copy to clipboard operation
gettext-extractor copied to clipboard

Custom parser e.g. JSON

Open sfc-gh-kbregula opened this issue 6 months ago • 0 comments

Hello,

I am working on a website, parts of it are downloaded and saved as JSON, and then the server loads and displays them.

However, I want the titles and short descriptions to be translated, so I wrote a JsonParser and JSPN Path Extractor that reads a JSON file and then extracts messages.

Its usage looks like below:

JsonParser.createFromExtractor(extractor, [
  JsonExtractors.jsonPath('$..title'),
  JsonExtractors.jsonPath('$..summary'),
]).parseFilesGlob('./generated/**/*.json');

Unfortunately while implementing I noticed that the Parser class is not public.

For now I have a workaround:

const { Parser } = require('gettext-extractor/dist/parser');

Ideally, this class would be public and I could import it directly from the package.

Best regards, Kamil Breguła

sfc-gh-kbregula avatar Aug 08 '24 14:08 sfc-gh-kbregula