summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-04-30 11:15:48 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:23 +0100
commit3a685d40c0280f930e959b32dedf1b3270e37a6e (patch)
treed738396330ee9a1654680a148e5cbbd8fba354f9 /src/lib/elua
parent093c7aa596122177cda128236dd42df0650075f6 (diff)
elua lib: add a func to retrieve the current translation lang
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/elua.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index be85d94d71..3e1a715a98 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -258,9 +258,29 @@ _elua_gettext_bind_textdomain(lua_State *L)
258#endif 258#endif
259} 259}
260 260
261static int
262_elua_get_message_language(lua_State *L)
263{
264 const char *e;
265 e = getenv("LANGUAGE");
266 if (e && e[0]) goto success;
267 e = getenv("LC_ALL");
268 if (e && e[0]) goto success;
269 e = getenv("LC_MESSAGES");
270 if (e && e[0]) goto success;
271 e = getenv("LANG");
272 if (e && e[0]) goto success;
273 lua_pushnil(L);
274 return 1;
275success:
276 lua_pushstring(L, e);
277 return 1;
278};
279
261const luaL_reg gettextlib[] = 280const luaL_reg gettextlib[] =
262{ 281{
263 { "bind_textdomain", _elua_gettext_bind_textdomain }, 282 { "bind_textdomain", _elua_gettext_bind_textdomain },
283 { "get_message_language", _elua_get_message_language },
264 { NULL, NULL } 284 { NULL, NULL }
265}; 285};
266 286