summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-12-12 10:44:58 +0000
committerDaniel Kolesa <d.kolesa@samsung.com>2014-12-12 10:44:58 +0000
commit784045df9ae73f4f74b52b5f2cc7a6254b9b7c1d (patch)
tree988a2444aa9cb16cd867e45015a57fb34d5425d6 /src/bin
parent56a8f13e5c9370a8a59c8b96a225250bda376e05 (diff)
elua: move i18n setup to the library
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elua/main.c49
1 files changed, 1 insertions, 48 deletions
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index 4b8b40fa2f..789ee06a9f 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -326,40 +326,6 @@ const luaL_reg cutillib[] =
326 { NULL , NULL } 326 { NULL , NULL }
327}; 327};
328 328
329static int
330elua_gettext_bind_textdomain(lua_State *L)
331{
332#ifdef ENABLE_NLS
333 const char *textdomain = luaL_checkstring(L, 1);
334 const char *dirname = luaL_checkstring(L, 2);
335 const char *ret;
336 if (!textdomain[0] || !strcmp(textdomain, PACKAGE))
337 {
338 lua_pushnil(L);
339 lua_pushliteral(L, "invalid textdomain");
340 return 2;
341 }
342 if (!(ret = bindtextdomain(textdomain, dirname)))
343 {
344 lua_pushnil(L);
345 lua_pushstring(L, strerror(errno));
346 return 2;
347 }
348 bind_textdomain_codeset(textdomain, "UTF-8");
349 lua_pushstring(L, ret);
350 return 1;
351#else
352 lua_pushliteral(L, "");
353 return 1;
354#endif
355}
356
357const luaL_reg gettextlib[] =
358{
359 { "bind_textdomain", elua_gettext_bind_textdomain },
360 { NULL, NULL }
361};
362
363static void 329static void
364elua_print_help(const char *pname, FILE *stream) 330elua_print_help(const char *pname, FILE *stream)
365{ 331{
@@ -413,12 +379,6 @@ elua_main(lua_State *L)
413 int argc = m->argc; 379 int argc = m->argc;
414 char **argv = m->argv; 380 char **argv = m->argv;
415 381
416#ifdef ENABLE_NLS
417 char *(*dgettextp)(const char*, const char*) = dgettext;
418 char *(*dngettextp)(const char*, const char*, const char*, unsigned long)
419 = dngettext;
420#endif
421
422 elua_progname = (argv[0] && argv[0][0]) ? argv[0] : "elua"; 382 elua_progname = (argv[0] && argv[0][0]) ? argv[0] : "elua";
423 383
424 while ((ch = getopt_long(argc, argv, "+LhC:M:A:e:l:I:E", lopt, NULL)) != -1) 384 while ((ch = getopt_long(argc, argv, "+LhC:M:A:e:l:I:E", lopt, NULL)) != -1)
@@ -507,14 +467,7 @@ elua_main(lua_State *L)
507 m->status = 1; 467 m->status = 1;
508 return 0; 468 return 0;
509 } 469 }
510 lua_createtable(L, 0, 0); 470 elua_state_setup_i18n(L);
511 luaL_register(L, NULL, gettextlib);
512#ifdef ENABLE_NLS
513 lua_pushlightuserdata(L, *((void**)&dgettextp));
514 lua_setfield(L, -2, "dgettext");
515 lua_pushlightuserdata(L, *((void**)&dngettextp));
516 lua_setfield(L, -2, "dngettext");
517#endif
518 lua_call(L, 1, 0); 471 lua_call(L, 1, 0);
519 472
520 elua_register_cache(L); 473 elua_register_cache(L);