You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,7 @@
1
1
# Dart gettext mo/po parser
2
2
3
3
Parse and compile gettext po and mo files with dart.
4
-
Port of npm package [gettext-parser](https://github.com/smhg/gettext-parser).
5
-
6
-
## Readiness
7
-
8
-
-[x] Mo parse
9
-
-[ ] Mo compile
10
-
-[x] Po parse
11
-
-[ ] Po compile
4
+
Ported [gettext-parser](https://github.com/smhg/gettext-parser) npm package to dartlang.
12
5
13
6
## Usage
14
7
@@ -23,27 +16,42 @@ Import library:
23
16
import 'package:gettext_parser/gettext_parser.dart' as gettextParser;
24
17
```
25
18
26
-
### Parse Mo Files:
19
+
### Parse .po files:
20
+
```dart
21
+
Map translateTable = gettextParser.po.parse(
22
+
file.readAsStringSync(),
23
+
);
24
+
```
25
+
26
+
### Parse .mo files:
27
27
```dart
28
28
Map translateTable = gettextParser.mo.parse(
29
29
file.readAsBytesSync(),
30
30
);
31
31
```
32
32
33
-
### Parse Po Files:
33
+
### Compile .po files:
34
34
```dart
35
-
Map translateTable = gettextParser.po.parse(
36
-
file.readAsStringSync(),
35
+
String data = gettextParser.po.compile(
36
+
translateTable,
37
+
);
38
+
```
39
+
40
+
### Compile .mo files:
41
+
```dart
42
+
UInt8List data = gettextParser.mo.compile(
43
+
translateTable,
37
44
);
38
45
```
39
46
40
47
## Encoding
41
-
`gettext_parser` use `Encoding` interface for encoding and decoding charsets from `dart:convert` package with utf8, base64, latin1 built-in encoders. If you need other encoding you could implement `Encoding` interface by your own.
48
+
`gettext_parser` use `Encoding` interface for encoding and decoding charsets from `dart:convert` package with utf8, base64, latin1 built-in encoders.
49
+
If you need other encoding you could implement `Encoding` interface by your own.
Notice that the structure has both a `headers` object and a `""` translation with the header string. When compiling the structure to a *mo* or a *po* file, the `headers` object is used to define the header. Header string in the `""` translation is just for reference (includes the original unmodified data) but will not be used when compiling. So if you need to add or alter header values, use only the `headers` object.
114
+
Notice that the structure has both a `headers` object and a `""` translation with the header string.
115
+
When compiling the structure to a *mo* or a *po* file, the `headers` object is used to define the header.
116
+
Header string in the `""` translation is just for reference (includes the original unmodified data) but
117
+
will not be used when compiling. So if you need to add or alter header values, use only the `headers` object.
0 commit comments