forked from enlightenment/efl
elua lib: add a func to retrieve the current translation lang
This commit is contained in:
parent
093c7aa596
commit
3a685d40c0
|
@ -258,9 +258,29 @@ _elua_gettext_bind_textdomain(lua_State *L)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
_elua_get_message_language(lua_State *L)
|
||||
{
|
||||
const char *e;
|
||||
e = getenv("LANGUAGE");
|
||||
if (e && e[0]) goto success;
|
||||
e = getenv("LC_ALL");
|
||||
if (e && e[0]) goto success;
|
||||
e = getenv("LC_MESSAGES");
|
||||
if (e && e[0]) goto success;
|
||||
e = getenv("LANG");
|
||||
if (e && e[0]) goto success;
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
success:
|
||||
lua_pushstring(L, e);
|
||||
return 1;
|
||||
};
|
||||
|
||||
const luaL_reg gettextlib[] =
|
||||
{
|
||||
{ "bind_textdomain", _elua_gettext_bind_textdomain },
|
||||
{ "get_message_language", _elua_get_message_language },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ local M = {}
|
|||
local gettext = ...
|
||||
|
||||
local bind_textdomain = gettext.bind_textdomain
|
||||
local bind_textdomain_codeset = gettext.bind_textdomain_codeset
|
||||
local dgettext = gettext.dgettext
|
||||
local dngettext = gettext.dngettext
|
||||
|
||||
|
|
Loading…
Reference in New Issue