<commit_before>Jed Gettext Parser
==================

JavaScript Gettext `.mo` file parsing for [Jed](https://github.com/slexaxton/Jed/).

[![Build Status](https://travis-ci.org/WrinklyNinja/jed-gettext-parser.svg?branch=master)](https://travis-ci.org/WrinklyNinja/jed-gettext-parser)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/oliverhamlet.svg)](https://saucelabs.com/u/oliverhamlet)

## Introduction

[Gettext](https://www.gnu.org/software/gettext/) is an old translation standard with implementations in many languages. It's one that localisation-aware programmers and translators are likely to be familiar with.

[Jed](https://github.com/slexaxton/Jed/) provides a very nice interface for translation using Gettext in Javascript.

Jed doesn't supply Gettext translation file parsers, so this library can act as the bridge between Gettext binary files and Jed. Maybe in future it will also gain the ability to parse `.po` files.

*Note: Jed Gettext Parser is made to work with Jed, but is a third-party library. Please direct any support queries to this repository's issue tracker, and [the author](https://github.com/WrinklyNinja).*

## Install

Jed Gettext Parser can be loaded as a browser global, an AMD module, or in Node. It requires support for:

* [Typed Arrays](http://caniuse.com/#feat=typedarrays) ([polyfill](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js))
* Encoding API: Natively supported in Firefox 20 and Chromium 38, polyfill [here](https://github.com/inexorabletash/text-encoding). 

Node supports Typed Arrays, and npm will automatically handle the Encoding API polyfill as a dependency.

##### Browser Global

```
<script src="jedGettextParser.js"></script>
<script>
// Use jedGettextParser
</script>
```

##### AMD Module

```
require(['jedGettextParser'], function(jedGettextParser) {
    // Use jedGettextParser
});
```

##### Node

```
npm install jed-gettext-parser
```

```
var jedGettextParser = require('jed-gettext-parser');
// Use jedGettextParser
```

## Usage

Once you've loaded Jed and Jed Gettext Parser, they can can be used together:

```
var moBuffer = new ArrayBuffer();
// Fill the moBuffer with the contents of a .mo file in whatever way you like.

// locale_data is an object holding locale data as expected by Jed.
var locale_data = jedGettextParser.mo.parse(moBuffer);

// Now load using Jed.
var i18n = new Jed({
    'locale_data': locale_data,
    'domain': 'messages'
});
```

#### API
    
The library currently exposes only one function:

```
var data = jedGettextParser.mo.parse(buffer[, options]);<commit_msg>More Sauce Labs inconsistency...<commit_after>Jed Gettext Parser
==================

JavaScript Gettext `.mo` file parsing for [Jed](https://github.com/slexaxton/Jed/).

[![Build Status](https://travis-ci.org/WrinklyNinja/jed-gettext-parser.svg?branch=v1.0.0)](https://travis-ci.org/WrinklyNinja/jed-gettext-parser)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/oliverhamlet.svg)](https://saucelabs.com/u/oliverhamlet)

## Introduction

[Gettext](https://www.gnu.org/software/gettext/) is an old translation standard with implementations in many languages. It's one that localisation-aware programmers and translators are likely to be familiar with.

[Jed](https://github.com/slexaxton/Jed/) provides a very nice interface for translation using Gettext in Javascript.

Jed doesn't supply Gettext translation file parsers, so this library can act as the bridge between Gettext binary files and Jed. Maybe in future it will also gain the ability to parse `.po` files.

*Note: Jed Gettext Parser is made to work with Jed, but is a third-party library. Please direct any support queries to this repository's issue tracker, and [the author](https://github.com/WrinklyNinja).*

## Install

Jed Gettext Parser can be loaded as a browser global, an AMD module, or in Node. It requires support for:

* [Typed Arrays](http://caniuse.com/#feat=typedarrays) ([polyfill](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js))
* Encoding API: Natively supported in Firefox 20 and Chromium 38, polyfill [here](https://github.com/inexorabletash/text-encoding).

Node supports Typed Arrays, and npm will automatically handle the Encoding API polyfill as a dependency.

##### Browser Global

```
<script src="jedGettextParser.js"></script>
<script>
// Use jedGettextParser
</script>
```

##### AMD Module

```
require(['jedGettextParser'], function(jedGettextParser) {
    // Use jedGettextParser
});
```

##### Node

```
npm install jed-gettext-parser
```

```
var jedGettextParser = require('jed-gettext-parser');
// Use jedGettextParser
```

## Usage

Once you've loaded Jed and Jed Gettext Parser, they can can be used together:

```
var moBuffer = new ArrayBuffer();
// Fill the moBuffer with the contents of a .mo file in whatever way you like.

// locale_data is an object holding locale data as expected by Jed.
var locale_data = jedGettextParser.mo.parse(moBuffer);

// Now load using Jed.
var i18n = new Jed({
    'locale_data': locale_data,
    'domain': 'messages'
});
```

#### API

The library currently exposes only one function:

```
var data = jedGettextParser.mo.parse(buffer[, options]);
{'fraction_non_alphanumeric': 0.130792799693604, 'fraction_numerical': 0.002872462657985446, 'mean_word_length': 4.752202643171806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 20, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1581019', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1578, 'n_words': 524}