summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mszulecki2007-06-11 17:45:08 +0000
committerGravatar mszulecki2007-06-11 17:45:08 +0000
commitc6421dddc6ede5f92a4626899083e9eaece0f380 (patch)
tree3ee51096795f7da377c42b8737ba48fe403b8a5a
parentef14adf712b23fce2867a4df9aa6af26ff34e58e (diff)
downloaddskel-c6421dddc6ede5f92a4626899083e9eaece0f380.tar.gz
dskel-c6421dddc6ede5f92a4626899083e9eaece0f380.tar.bz2
Fix i18n functionality
git-svn-id: http://svn.sukimashita.com/repos/dskel/trunk@21 4281df72-ff29-0410-8fee-2d9ac0c5f5a7
-rw-r--r--config.d.in1
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am2
-rw-r--r--src/catalog.d12
-rwxr-xr-xsrc/helloworld.d2
5 files changed, 11 insertions, 7 deletions
diff --git a/config.d.in b/config.d.in
index da86825..3c6b56a 100644
--- a/config.d.in
+++ b/config.d.in
@@ -7,6 +7,7 @@ s PACKAGE = "@PACKAGE@";
s PACKAGE_NAME = "@PACKAGE_NAME@";
s PACKAGE_STRING = "@PACKAGE_STRING@";
s PACKAGE_TARNAME = "@PACKAGE_TARNAME@";
+s PACKAGE_LOCALE_DIR = "@PACKAGE_LOCALE_DIR@";
s VERSION = "@VERSION@";
s GDC = "@GDC@";
s GDC_VERSION = "@GDC_VERSION@";
diff --git a/configure.ac b/configure.ac
index 396ca93..8ef9d7b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,7 @@ dnl TODO: Check for Phobos Library
dnl TODO: Check for duit GTK+ D Bindings
AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)
+AC_SUBST(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale")
AC_CONFIG_FILES([
config.d
diff --git a/src/Makefile.am b/src/Makefile.am
index 92d8df8..7a990f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,7 +11,7 @@ libtestlibrary_a_SOURCES = testlibrary.d
bin_PROGRAMS = helloworld
helloworld_SOURCES = helloworld.d catalog.d
-helloworld_LDADD = $(DEPS_LIBS) $(top_srcdir)/config.d libtestlibrary.a testshlibrary.d libtestshlibrary.la
+helloworld_LDADD = $(DEPS_LIBS) $(top_srcdir)/config.d libtestlibrary.a testshlibrary.d libtestshlibrary.la -lunwind
DFLAGS += -I$(top_srcdir) -I$(srcdir)
diff --git a/src/catalog.d b/src/catalog.d
index 415b34f..fae44ac 100644
--- a/src/catalog.d
+++ b/src/catalog.d
@@ -2,16 +2,18 @@ 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);
+static extern (C) char* setlocale(int category, char* locale);
+static extern (C) char* bindtextdomain(char* domainname, char* localedir);
+static extern (C) char* bind_textdomain_codeset(char* domainname, char* localedir);
+static extern (C) char* textdomain(char* domainname);
+static extern (C) char* gettext(char* instring);
+static extern (C) char* ngettext(char* singular, char* plural, int n);
public static class Catalog
{
public static void Init(char[] packageid, char[] localedir)
{
+ setlocale(6, "");
bindtextdomain(std.string.toStringz(packageid), std.string.toStringz(localedir));
bind_textdomain_codeset(std.string.toStringz(packageid), "UTF-8");
textdomain(std.string.toStringz(packageid));
diff --git a/src/helloworld.d b/src/helloworld.d
index db25741..dcb4a37 100755
--- a/src/helloworld.d
+++ b/src/helloworld.d
@@ -7,7 +7,7 @@ import catalog;
void main(char[][] args)
{
// Internationalization Example
- Catalog.Init("i18n","./locale");
+ Catalog.Init(config.PACKAGE, config.PACKAGE_LOCALE_DIR);
writefln(Catalog.GetString("Hello!"));