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.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