Skip to content

Commit 81c2d1f

Browse files
committed
updated readme
1 parent db1a421 commit 81c2d1f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Gettext translator
2+
23
Javascript gettext translator. Use [gettext/gettext](https://github.com/oscarotero/Gettext) PHP library to generate and modify the messages.
34

45
Supports:
@@ -7,35 +8,48 @@ Supports:
78
* CommonJS
89
* Global js
910

11+
## Installation
12+
13+
Using bower:
14+
15+
```
16+
bower install gettext-translator
17+
```
18+
19+
Using npm:
20+
21+
```
22+
npm install gettext-translator
23+
```
24+
1025
## Usage
1126

12-
Use the Json generator of the [gettext/gettext](https://github.com/oscarotero/Gettext) library:
27+
Use the Json generator of the [gettext/gettext](https://github.com/oscarotero/Gettext) library to export the translations to json:
1328

1429
```php
1530
use Gettext\Translations;
1631

17-
//Scan the po file with the translations
32+
//Load the po file with the translations
1833
$translations = Translations::fromPoFile('locales/gl.po');
1934

2035
//Export to a json file
2136
$translations->toJsonFile('locales/gl.json');
2237
```
2338

24-
Load the json file in your javascript (for example, using webpack) and use it
39+
Load the json file in your browser (for example, using webpack) and use it
2540

2641
```js
2742
var Translator = require('gettext-translator');
2843
var translations = require('locales/gl.json');
2944

3045
var i18n = new Translator(translations);
3146

32-
3347
console.log(i18n.gettext('hello world')); //ola mundo
3448
```
3549

3650
## Sprintf
3751

38-
This library includes [sprintf](https://github.com/alexei/sprintf.js) dependency implemented in the short methods:
52+
This library includes [sprintf](https://github.com/alexei/sprintf.js) dependency implemented in the short methods like `__`, `n__`, etc...:
3953

4054
```js
4155
i18n.__('Hello %s', 'world'); //Hello world

0 commit comments

Comments
 (0)