File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -35,29 +35,29 @@ async function getTranslator() {
35
35
return new Translator (translations);
36
36
}
37
37
38
- const translator = await getTranslator ();
38
+ const t = await getTranslator ();
39
39
40
- translator .gettext (' hello world' ); // ola mundo
40
+ t .gettext (' hello world' ); // ola mundo
41
41
```
42
42
43
43
## Variables
44
44
45
45
You can add variables to the translations. For example:
46
46
47
47
``` js
48
- translator .gettext (' hello :who' , {' :who' : ' world' }); // ola world
48
+ t .gettext (' hello :who' , {' :who' : ' world' }); // ola world
49
49
```
50
50
51
51
There's also a basic support o sprintf (only ` %s ` and ` %d ` )
52
52
53
53
``` js
54
- translator .gettext (' hello %s' , ' world' ); // ola world
54
+ t .gettext (' hello %s' , ' world' ); // ola world
55
55
```
56
56
57
57
To customize the translator formatter, just override the ` format ` method:
58
58
59
59
``` js
60
- translator .format = function (text , ... args ) {
60
+ t .format = function (text , ... args ) {
61
61
// Your custom format here
62
62
}
63
63
```
@@ -69,8 +69,8 @@ Like in the [php version](https://github.com/php-gettext/Translator), there are
69
69
``` js
70
70
// Both functions does the same
71
71
72
- translator .gettext (' Foo' );
73
- translator .__ (' Foo' );
72
+ t .gettext (' Foo' );
73
+ t .__ (' Foo' );
74
74
```
75
75
76
76
## API
You can’t perform that action at this time.
0 commit comments