CSM: Add a way to get current locale from CSM
authorlisacvuk <lisacvukhome@gmail.com>
Sat, 28 Oct 2017 06:56:10 +0000 (08:56 +0200)
committerparamat <mat.gregory@virginmedia.com>
Sun, 29 Oct 2017 12:05:16 +0000 (12:05 +0000)
doc/client_lua_api.md
src/script/lua_api/l_client.cpp
src/script/lua_api/l_client.h

index fb00ada661151e9e2d63d559f8be9d916ec924e4..d8e2da69c1cbc0372fe224d8be147802387b186f 100644 (file)
@@ -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"
index ba22a04242c646c7f72ea7f7ac4885f8ca4065f7..a3605be79c9b675a5e5cd364bd7884f17c4eb583 100644 (file)
@@ -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);
 }
index 791038f7dc9fa5d99658469cddccb2b5029161e6..b0ece72052502da62902ee871fb1b37c429bbbff 100644 (file)
@@ -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);