summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/catalog.d18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/catalog.d b/src/catalog.d
index fd60545..415b34f 100644
--- a/src/catalog.d
+++ b/src/catalog.d
@@ -1,19 +1,29 @@
module catalog;
+import std.string;
+
+private static extern (C) char* bindtextdomain(char* domainname, char* localedir);
+private static extern (C) char* bind_textdomain_codeset(char* domainname, char* localedir);
+private static extern (C) char* textdomain(char* domainname);
+private static extern (C) char* gettext(char* instring);
+private static extern (C) char* ngettext(char* singular, char* plural, int n);
+
public static class Catalog
{
public static void Init(char[] packageid, char[] localedir)
{
-
+ bindtextdomain(std.string.toStringz(packageid), std.string.toStringz(localedir));
+ bind_textdomain_codeset(std.string.toStringz(packageid), "UTF-8");
+ textdomain(std.string.toStringz(packageid));
}
public static char[] GetString(char[] s)
{
- return s;
+ return std.string.toString(gettext(std.string.toStringz(s)));
}
- public static char[] GetPluralString(char[] s, char[] p, char[] n)
+ public static char[] GetPluralString(char[] s, char[] p, int n)
{
- return s;
+ return std.string.toString(ngettext(std.string.toStringz(s), std.string.toStringz(p), n));
}
}