Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Updated docs and examples to match new [ESM standard](https://github.com/smhg/gettext-parser/releases/tag/v8.0.0).
  • Loading branch information
vHeemstra authored Jul 10, 2024
1 parent d8dcbee commit 7f239ee
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Parse and compile gettext *po* and *mo* files with node.js, nothing more, nothin

Include the library:

var gettextParser = require("gettext-parser");
import gettextParser from "gettext-parser";

### Parse PO files

Expand All @@ -34,7 +34,8 @@ Method returns gettext-parser specific translation object (see below)
**Example**

```javascript
var input = require('fs').readFileSync('en.po');
import { readFileSync } from 'node:fs';
var input = readFileSync('en.po');
var po = gettextParser.po.parse(input);
console.log(po.translations['']); // output translations for the default context
```
Expand All @@ -53,7 +54,8 @@ Where
**Example**

```javascript
var input = require('fs').createReadStream('en.po');
import { createReadStream } from 'node:fs';
var input = createReadStream('en.po');
var po = gettextParser.po.createParseStream();
input.pipe(po);
po.on('data', function(data){
Expand All @@ -79,11 +81,12 @@ Where
**Example**

```javascript
import { writeFileSync } from 'node:fs';
var data = {
...
};
var output = gettextParser.po.compile(data);
require('fs').writeFileSync('filename.po', output);
writeFileSync('filename.po', output);
```

###
Expand All @@ -104,7 +107,8 @@ Method returns gettext-parser specific translation object (see below)
**Example**

```javascript
var input = require('fs').readFileSync('en.mo');
import { readFileSync } from 'node:fs';
var input = readFileSync('en.mo');
var mo = gettextParser.mo.parse(input);
console.log(mo.translations['']); // output translations for the default context
```
Expand All @@ -122,11 +126,12 @@ Where
**Example**

```javascript
import { writeFileSync } from 'node:fs';
var data = {
...
};
var output = gettextParser.mo.compile(data);
require('fs').writeFileSync('filename.mo', output);
writeFileSync('filename.mo', output);
```

### Notes
Expand Down

0 comments on commit 7f239ee

Please sign in to comment.