forked from FreeSlave/mofile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgettext.d
More file actions
32 lines (30 loc) · 767 Bytes
/
gettext.d
File metadata and controls
32 lines (30 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/+dub.sdl:
name "gettext"
dependency "mofile" path="../"
+/
import std.stdio;
import std.conv : to;
import mofile;
int main(string[] args)
{
if (args.length < 3) {
stderr.writefln("Usage: %s <file.mo> <msgid> [msgid_plural] [number]", );
return 1;
}
string fileName = args[1];
string msgid = args[2];
auto moFile = MoFile(fileName);
if (args.length > 3) {
if (args.length < 5) {
stderr.writefln("Must provide a number");
return 1;
} else {
string msgid_plural = args[3];
const int n = args[4].to!int;
writefln("%s %s", n, moFile.ngettext(msgid, msgid_plural, n));
}
} else {
writeln(moFile.gettext(msgid));
}
return 0;
}