# xgettext-webird

> Extract translatable strings from templates

Latest version **0.1.1** (published 2015-11-13) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install xgettext-webird
pnpm add xgettext-webird
yarn add xgettext-webird
bun add xgettext-webird
```

Provides the command `xgettext-webird`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2015-11-13 |
| First published | 2015-11-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 8 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Guillaume Marty |
| Maintainers | dschissler |
| Keywords | template, gettext, i18n |

## Links

- npm: https://www.npmjs.com/package/xgettext-webird
- Repository: https://github.com/perchlayer/xgettext-webird
- Issues: https://github.com/perchlayer/xgettext-webird/issues
- npm.io page: https://npm.io/package/xgettext-webird

## Dependencies (8)

- [async](https://npm.io/package/async.md) 1.5.0
- [colors](https://npm.io/package/colors.md) 1.1.2
- [optimist](https://npm.io/package/optimist.md) 0.6.1
- [readdirp](https://npm.io/package/readdirp.md) 2.0.0
- [gettext-swig](https://npm.io/package/gettext-swig.md) 0.2.0
- [gettext-volt](https://npm.io/package/gettext-volt.md) 0.2.1
- [gettext-parser](https://npm.io/package/gettext-parser.md) 1.1.2
- [gettext-handlebars](https://npm.io/package/gettext-handlebars.md) 0.4.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2015-11-13
- 0.1.0 — 2015-11-13

## README

# xgettext-webird [![build status](https://secure.travis-ci.org/perchlayer/xgettext-webird.png)](http://travis-ci.org/perchlayer/xgettext-webird)
Extracts translatable strings from source. Identical to [xgettext(1)](http://www.gnu.org/software/gettext/manual/gettext.html#xgettext-Invocation) but for template languages.

*tl;dr* **Get translatable strings from templates into Poedit.**

## Template language support
* Handlebars (using [gettext-handlebars](https://github.com/smhg/gettext-handlebars))
* Swig (using [gettext-swig](https://github.com/smhg/gettext-swig))
* Volt (using [gettext-volt](https://github.com/perchlayer/gettext-volt))

React's **JSX** and **Jade** are todos (PRs are much appreciated).

## General workflow
In the following Handlebars example translatable content is passed to helpers (`_` and `ngettext`):
``` html
<button>{{_ "Sign in"}}</button>

<p>{{count}} {{ngettext "country" "countries" count}}</p>
```

With Handlebars, this requires helpers being registered:
``` javascript
Handlebars.registerHelper('_', function(msgid) {
  return i18n.gettext(msgid);
});

Handlebars.registerHelper('ngettext', function(msgid, plural, count) {
  return i18n.ngettext(msgid, plural, count);
});
```
What this `i18n` object refers to is up to you. Some (client/server) options are:
* [node-gettext](https://github.com/andris9/node-gettext)
* [Jed](http://slexaxton.github.io/Jed/)

**xgettext-webird** parses the strings above out of your templates into gettext's PO files.
These PO files are then translated and compiled to binary MO files using applications like [Poedit](http://www.poedit.net).
The MO files are passed as input the i18n library (above).

## Installation
``` bash
$ npm install -g xgettext-webird
```

## Usage
``` bash
$ xgettext-webird [OPTION] [INPUTFILE]...
```
#### Options
* `-D|--directory` add directory to list for input files search.
* `-o|--output` write output to specified file (default: stdout).
* `-L|--language` specifies the language of the input files (default: determine from file extension). Use the language's full name from the **template language support** list above.
* `--from-code` encoding of input files (default: `ascii`).
* `-k|--keyword` additional keyword to be looked for (default: `_,gettext,ngettext:1,2`).
* `--force-po` write PO file even if empty (default: `false`).
* `--no-location` don't add file and line references (default: `false`).

#### In Poedit
Go to *File* - *Preferences...* in Poedit and add a new parser in the *Parsers* tab:

* **Nunjucks**
  * Language: `Nunjucks`
  * List of extensions...: `*.nunj`
  * Parser Command: `xgettext-webird -L Swig --force-po -o %o %C %K %F`
  * An item in keywords list: `-k %k`
  * An item in input files list: `%f`
  * Source code charset: `--from-code=%c`
* **Volt**
  * Language: `Volt`
  * List of extensions...: `*.volt`
  * Parser Command: `xgettext-webird -L Volt --force-po -o %o %C %K %F`
  * An item in keywords list: `-k %k`
  * An item in input files list: `%f`
  * Source code charset: `--from-code=%c`

Please note that in this Windows example you have to use `xgettext-webird.cmd`. The `.cmd` extension should not be there on *nix platforms.

## Development

* Clone repository and run `npm install`.
* Run `npm test` to lint & test.

## Note

xgettext-template initial development was founded by Dijiwan.  This xgettext-webird project is a fork of xgettext-template.

---
_Source: https://npm.io/package/xgettext-webird · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
