[seed] [gettext] Add a tiny gettext module that provides a binding to _()
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [gettext] Add a tiny gettext module that provides a binding to _()
- Date: Wed, 24 Jun 2009 22:17:53 +0000 (UTC)
commit 950cccdefb33aef4b5ba2cfd928d7a0f0394d4d8
Author: Tim Horton <hortont svn gnome org>
Date: Wed Jun 24 18:13:17 2009 -0400
[gettext] Add a tiny gettext module that provides a binding to _()
This seems like a strange place for this to go, but I can't find
any other way to access gettext strings.
configure.ac | 10 ++++++++
modules/Makefile.am | 2 +-
modules/gettext/Makefile.am | 24 +++++++++++++++++++
modules/gettext/gettext.c | 52 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3ef2b69..08575ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -258,6 +258,14 @@ AM_CONDITIONAL(BUILD_CAIRO_MODULE, test "x$want_cairo_module" = "xyes")
AC_SUBST(BUILD_CAIRO_MODULE)
+dnl ==== gettext ====
+AC_ARG_ENABLE(gettext-module,
+ AC_HELP_STRING([--enable-gettext-module],
+ [enable the gettext Seed module. [default=yes]]),
+ [want_gettext_module=$enableval],[want_gettext_module="yes"])
+
+AM_CONDITIONAL(BUILD_GETTEXT_MODULE, test "x$want_gettext_module" = "xyes")
+AC_SUBST(BUILD_GETTEXT_MODULE)
dnl =========================turtle example====================================
AC_ARG_ENABLE(turtle-example,
@@ -416,6 +424,7 @@ modules/dbus/util/Makefile
modules/libxml/Makefile
modules/cairo/Makefile
modules/gtkbuilder/Makefile
+modules/gettext/Makefile
libseed/seed-path.h
])
@@ -442,6 +451,7 @@ Modules:
libxml.....................$want_libxml_module
cairo......................$want_cairo_module
gtkbuilder.................$want_gtkbuilder_module
+ gettext....................$want_gettext_module
Examples:
Turtle.....................$want_turtle_example
diff --git a/modules/Makefile.am b/modules/Makefile.am
index c29069e..9ec9bf8 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1 +1 @@
-SUBDIRS = example sqlite canvas Multiprocessing readline os sandbox dbus libxml cairo gtkbuilder
+SUBDIRS = example sqlite canvas Multiprocessing readline os sandbox dbus libxml cairo gtkbuilder gettext
diff --git a/modules/gettext/Makefile.am b/modules/gettext/Makefile.am
new file mode 100644
index 0000000..2fdf100
--- /dev/null
+++ b/modules/gettext/Makefile.am
@@ -0,0 +1,24 @@
+if BUILD_GETTEXT_MODULE
+
+seedlibdir = ${libdir}/seed
+
+seedlib_LTLIBRARIES = \
+ libgettext.la
+
+libgettext_la_SOURCES = \
+ gettext.c
+
+AM_CPPFLAGS = \
+ -I top_srcdir@/libseed/ \
+ $(GOBJECT_INTROSPECTION_CFLAGS)
+ $(SEED_DEBUG_CFLAGS) \
+ $(SEED_PROFILE_CFLAGS)
+
+libgettext_la_LDFLAGS = \
+ $(GOBJECT_INTROSPECTION_LDFLAGS) \
+ $(SEED_PROFILE_LIBS)
+
+endif
+
+
+
diff --git a/modules/gettext/gettext.c b/modules/gettext/gettext.c
new file mode 100644
index 0000000..b0e80c6
--- /dev/null
+++ b/modules/gettext/gettext.c
@@ -0,0 +1,52 @@
+#include <seed.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <glib/gi18n.h>
+
+SeedObject namespace_ref;
+SeedEngine *eng;
+
+static SeedValue
+seed_gettext_i18n (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ gchar * string_to_translate;
+
+ if (argument_count != 1)
+ {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "gettext.i18n expected 1 argument, got %zd",
+ argument_count);
+ return seed_make_null (ctx);
+ }
+
+ string_to_translate = seed_value_to_string (ctx, arguments[0], exception);
+
+ return seed_value_from_string (ctx, _(string_to_translate), exception);
+}
+
+static void
+seed_gettext_define_stuff ()
+{
+ seed_create_function(eng->context, "i18n",
+ (SeedFunctionCallback) seed_gettext_i18n,
+ namespace_ref);
+}
+
+SeedObject
+seed_module_init(SeedEngine *local_eng)
+{
+ eng = local_eng;
+ namespace_ref = seed_make_object (eng->context, NULL, NULL);
+ seed_value_protect (eng->context, namespace_ref);
+
+ seed_gettext_define_stuff();
+
+ return namespace_ref;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]