diff options
author | lisacvuk <lisacvukhome@gmail.com> | 2017-10-28 08:56:10 +0200 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-10-29 12:05:16 +0000 |
commit | c252ed506eb8324fbdea4b632116c2c7d06a8c9c (patch) | |
tree | 153d560f7794c1cf244219e2f643a9dd1a24da55 | |
parent | 241fe649f7357271d5c02c3d5f7a987ad7811d6d (diff) | |
download | minetest-c252ed506eb8324fbdea4b632116c2c7d06a8c9c.tar.gz minetest-c252ed506eb8324fbdea4b632116c2c7d06a8c9c.tar.bz2 minetest-c252ed506eb8324fbdea4b632116c2c7d06a8c9c.zip |
CSM: Add a way to get current locale from CSM
-rw-r--r-- | doc/client_lua_api.md | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_client.cpp | 8 | ||||
-rw-r--r-- | src/script/lua_api/l_client.h | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index fb00ada66..d8e2da69c 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -618,6 +618,7 @@ Minetest namespace reference ### Utilities * `minetest.get_current_modname()`: returns the currently loading mod's name, when we are loading a mod +* `minetest.get_language()`: returns the currently set gettext language. * `minetest.get_version()`: returns a table containing components of the engine version. Components: * `project`: Name of the project, eg, "Minetest" diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index ba22a0424..a3605be79 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -188,6 +188,13 @@ int ModApiClient::l_get_node_or_nil(lua_State *L) return 1; } +int ModApiClient::l_get_language(lua_State *L) +{ + char *locale = setlocale(LC_ALL, ""); + lua_pushstring(L, locale); + return 1; +} + int ModApiClient::l_get_wielded_item(lua_State *L) { Client *client = getClient(L); @@ -373,4 +380,5 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(take_screenshot); API_FCT(get_privilege_list); API_FCT(get_builtin_path); + API_FCT(get_language); } diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 791038f7d..b0ece7205 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -66,6 +66,8 @@ private: // get_node(pos) static int l_get_node_or_nil(lua_State *L); + static int l_get_language(lua_State *L); + // get_wielded_item() static int l_get_wielded_item(lua_State *L); |