summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-11-09 16:15:05 +0100
committersfan5 <sfan5@live.de>2019-11-11 14:06:48 +0100
commitc44318a253783dde37e3bb688e29927da3b4cac0 (patch)
tree67cd18e68ed0b9aa6a3d0182a6e44928c6fdafd5 /src/script
parent2c4cf508a9b94a76ce2ca7c7317258471a41c51d (diff)
downloadminetest-c44318a253783dde37e3bb688e29927da3b4cac0.tar.gz
minetest-c44318a253783dde37e3bb688e29927da3b4cac0.tar.bz2
minetest-c44318a253783dde37e3bb688e29927da3b4cac0.zip
[CSM] Fix and improve minetest.get_language()
Previously this method would accidentally reset the locale and break everything.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_client.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index fa369a360..4aa7d814d 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -230,9 +230,14 @@ int ModApiClient::l_get_node_or_nil(lua_State *L)
int ModApiClient::l_get_language(lua_State *L)
{
- char *locale = setlocale(LC_ALL, "");
+ char *locale = setlocale(LC_MESSAGES, NULL);
+ std::string lang = gettext("LANG_CODE");
+ if (lang == "LANG_CODE")
+ lang = "";
+
lua_pushstring(L, locale);
- return 1;
+ lua_pushstring(L, lang.c_str());
+ return 2;
}
int ModApiClient::l_get_wielded_item(lua_State *L)