summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-04-30 11:50:09 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:23 +0100
commit490deb93288d8401bff4f442d67f4df6a054f7c9 (patch)
tree103100685ee35fd53159272d2aded872fc79cfe5 /src/lib/elua
parent3a685d40c0280f930e959b32dedf1b3270e37a6e (diff)
elua lib: add API to retrieve lconv from lua
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/elua.c47
-rw-r--r--src/lib/elua/elua_private.h3
2 files changed, 49 insertions, 1 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 3e1a715a98..ed5a4e3786 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -277,10 +277,57 @@ success:
277 return 1; 277 return 1;
278}; 278};
279 279
280static int
281_elua_get_localeconv(lua_State *L)
282{
283 struct lconv *lc = localeconv();
284 lua_createtable(L, 0, 24);
285
286#define ELUA_LCF_S(name) \
287 lua_pushstring(L, lc->name); \
288 lua_setfield(L, -2, #name);
289
290#define ELUA_LCF_C(name) \
291 lua_pushinteger(L, (int)lc->name); \
292 lua_setfield(L, -2, #name);
293
294 ELUA_LCF_S(decimal_point);
295 ELUA_LCF_S(thousands_sep);
296 ELUA_LCF_S(grouping);
297 ELUA_LCF_S(int_curr_symbol);
298 ELUA_LCF_S(currency_symbol);
299 ELUA_LCF_S(mon_decimal_point);
300 ELUA_LCF_S(mon_thousands_sep);
301 ELUA_LCF_S(mon_grouping);
302 ELUA_LCF_S(positive_sign);
303 ELUA_LCF_S(negative_sign);
304
305 ELUA_LCF_C(frac_digits);
306 ELUA_LCF_C(p_cs_precedes);
307 ELUA_LCF_C(n_cs_precedes);
308 ELUA_LCF_C(p_sep_by_space);
309 ELUA_LCF_C(n_sep_by_space);
310 ELUA_LCF_C(p_sign_posn);
311 ELUA_LCF_C(n_sign_posn);
312 ELUA_LCF_C(int_frac_digits);
313 ELUA_LCF_C(int_p_cs_precedes);
314 ELUA_LCF_C(int_n_cs_precedes);
315 ELUA_LCF_C(int_p_sep_by_space);
316 ELUA_LCF_C(int_n_sep_by_space);
317 ELUA_LCF_C(int_p_sign_posn);
318 ELUA_LCF_C(int_n_sign_posn);
319
320#undef ELUA_LCF_S
321#undef ELUA_LCF_C
322
323 return 1;
324};
325
280const luaL_reg gettextlib[] = 326const luaL_reg gettextlib[] =
281{ 327{
282 { "bind_textdomain", _elua_gettext_bind_textdomain }, 328 { "bind_textdomain", _elua_gettext_bind_textdomain },
283 { "get_message_language", _elua_get_message_language }, 329 { "get_message_language", _elua_get_message_language },
330 { "get_localeconv", _elua_get_localeconv },
284 { NULL, NULL } 331 { NULL, NULL }
285}; 332};
286 333
diff --git a/src/lib/elua/elua_private.h b/src/lib/elua/elua_private.h
index 53b514e627..01d8e4b1ac 100644
--- a/src/lib/elua/elua_private.h
+++ b/src/lib/elua/elua_private.h
@@ -5,8 +5,9 @@
5# include <config.h> 5# include <config.h>
6#endif 6#endif
7 7
8#include <locale.h>
9
8#ifdef ENABLE_NLS 10#ifdef ENABLE_NLS
9# include <locale.h>
10# include <libintl.h> 11# include <libintl.h>
11# define _(x) dgettext(PACKAGE, x) 12# define _(x) dgettext(PACKAGE, x)
12#else 13#else