From ef14adf712b23fce2867a4df9aa6af26ff34e58e Mon Sep 17 00:00:00 2001 From: mszulecki Date: Sun, 10 Jun 2007 21:38:00 +0000 Subject: Implement intl support. git-svn-id: http://svn.sukimashita.com/repos/dskel/trunk@20 4281df72-ff29-0410-8fee-2d9ac0c5f5a7 --- src/catalog.d | 18 ++++++++++++++---- 1 file 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)); } } -- cgit v1.1-32-gdbae