🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

gettext-extract

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettext-extract

CLI for extracting Gettext messages from JavaScript, TypeScript, JSX and HTML

latest
npmnpm
Version
2.0.1
Version published
Weekly downloads
1K
-46.93%
Maintainers
1
Weekly downloads
 
Created
Source

:speech_balloon: gettext-extract

NPM version Build status Node version XO code style License

CLI for extracting Gettext messages from JavaScript, TypeScript, JSX and HTML

This CLI is essentially a convenience wrapper around gettext-extractor, all the processing is done by this library.

Installation

npm install gettext-extract

Usage

Usage: gettext-extract [options]

Options:
  -c, --config  Config file [default: .gettext.json]
  -o, --output  Output file [default: template.pot]
  -h, --help    Show this help

Configuration

Configuration for message extraction can be provided using a .gettext.json file, a custom JSON file using the --config CLI option or by adding a gettext object in your package.json.

Here is an example configuration (remove comments for valid JSON):

{
  "js": {
    "parsers": [
      {
        "expression": "gettext",
        "arguments": {
          "text": 0
        }
      },
      {
        "expression": "ngettext",
        "arguments": {
          "text": 0,
          "textPlural": 1
        }
      },
      {
        "expression": "pgettext",
        "arguments": {
          "context": 0,
          "text": 1
        }
      }
    ],
    "glob": {
      // [node-glob pattern(https://github.com/isaacs/node-glob#glob-primer) to match your JS files
      "pattern": "src/**/*.ts",
      // Add any [node-glob options](https://github.com/isaacs/node-glob#options) here
      "options": {
        "ignore": "src/**/*.spec.ts"
      }
    }
  },
  "html": {
    "parsers": [
      {
        // Extract message from content of the HTML element with the specified CSS selector
        "element": "[translate]",
        "attributes": {
          "textPlural": "translate-plural",
          "context": "translate-context"
        }
      },
      {
        // Extract message from attribute of the HTML element
        "attribute": "translate-text",
        "attributes": {
          "textPlural": "translate-plural",
          "context": "translate-context"
        }
      }
    ],
    "glob": {
      "pattern": "src/**/*.html"
    }
  },
  //
  "headers": {
    "Language": ""
  },
  "output": "translations/template.pot"
}

At least one valid parser (JS or HTML) with glob pattern must be present, everything else is optional.

You can fin additional information concerning the JavaScript / TypeScript / JSX or HTML parsers on the gettext-extractor wiki.

Keywords

gettext

FAQs

Package last updated on 20 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts