summaryrefslogtreecommitdiff
path: root/src/lib/elua/elua.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elua/elua.c')
-rw-r--r--src/lib/elua/elua.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 44b5c32..3f3654e 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -360,14 +360,43 @@ _elua_get_localeconv(lua_State *L)
360 return 1; 360 return 1;
361}; 361};
362 362
363#ifdef ENABLE_NLS
364static int
365_elua_dgettext(lua_State *L)
366{
367 const char *domain = luaL_checkstring(L, 1);
368 const char *msgid = luaL_checkstring(L, 2);
369 char *ret = dgettext(domain, msgid);
370 if (!ret)
371 lua_pushnil(L);
372 else
373 lua_pushstring(L, ret);
374 return 1;
375}
376
377static int
378_elua_dngettext(lua_State *L)
379{
380 const char *domain = luaL_checkstring(L, 1);
381 const char *msgid = luaL_checkstring(L, 2);
382 const char *plmsgid = luaL_checkstring(L, 3);
383 char *ret = dngettext(domain, msgid, plmsgid, luaL_checklong(L, 4));
384 if (!ret)
385 lua_pushnil(L);
386 else
387 lua_pushstring(L, ret);
388 return 1;
389}
390#endif
391
363const luaL_Reg gettextlib[] = 392const luaL_Reg gettextlib[] =
364{ 393{
365 { "bind_textdomain", _elua_gettext_bind_textdomain }, 394 { "bind_textdomain", _elua_gettext_bind_textdomain },
366 { "get_message_language", _elua_get_message_language }, 395 { "get_message_language", _elua_get_message_language },
367 { "get_localeconv", _elua_get_localeconv }, 396 { "get_localeconv", _elua_get_localeconv },
368#ifdef ENABLE_NLS 397#ifdef ENABLE_NLS
369 { "dgettext", dgettext }, 398 { "dgettext", _elua_dgettext },
370 { "dgettext", dngettext }, 399 { "dngettext", _elua_dngettext },
371#endif 400#endif
372 { NULL, NULL } 401 { NULL, NULL }
373}; 402};