[seed] [gettext] Add textdomain binding, rename i18n->gettext for consistency
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [gettext] Add textdomain binding, rename i18n->gettext for consistency
- Date: Thu, 2 Jul 2009 04:36:53 +0000 (UTC)
commit a18b603ca8c82e0d4da7e9c7037f4d8fba4f249f
Author: Tim Horton <hortont svn gnome org>
Date: Thu Jul 2 00:32:14 2009 -0400
[gettext] Add textdomain binding, rename i18n->gettext for consistency
modules/gettext/gettext.c | 51 ++++++++++++++++++++++++++++++++++----------
1 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/modules/gettext/gettext.c b/modules/gettext/gettext.c
index e010f33..784dcbb 100644
--- a/modules/gettext/gettext.c
+++ b/modules/gettext/gettext.c
@@ -9,33 +9,60 @@ 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)
+seed_gettext_gettext (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
{
- gchar * string_to_translate;
+ gchar * msgid;
if (argument_count != 1)
{
seed_make_exception (ctx, exception, "ArgumentError",
- "gettext.i18n expected 1 argument, got %zd",
+ "gettext.gettext expected 1 argument, got %zd",
argument_count);
return seed_make_null (ctx);
}
- string_to_translate = seed_value_to_string (ctx, arguments[0], exception);
+ msgid = seed_value_to_string (ctx, arguments[0], exception);
- return seed_value_from_string (ctx, _(string_to_translate), exception);
+ return seed_value_from_string (ctx, gettext(msgid), exception);
+}
+
+static SeedValue
+seed_gettext_textdomain (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ gchar * domain_name;
+
+ if (argument_count != 1)
+ {
+ seed_make_exception (ctx, exception, "ArgumentError",
+ "gettext.textdomain expected 1 argument, got %zd",
+ argument_count);
+ return seed_make_null (ctx);
+ }
+
+ domain_name = seed_value_to_string (ctx, arguments[0], exception);
+
+ return seed_value_from_string (ctx, textdomain(domain_name), exception);
}
static void
seed_gettext_define_stuff ()
{
- seed_create_function(eng->context, "i18n",
- (SeedFunctionCallback) seed_gettext_i18n,
+ seed_create_function(eng->context, "gettext",
+ (SeedFunctionCallback) seed_gettext_gettext,
+ namespace_ref);
+
+ seed_create_function(eng->context, "textdomain",
+ (SeedFunctionCallback) seed_gettext_textdomain,
namespace_ref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]