Skip to content

Commit

Permalink
CSM: Add a way to get current locale from CSM
Browse files Browse the repository at this point in the history
  • Loading branch information
lisacvuk authored and paramat committed Oct 29, 2017
1 parent 241fe64 commit c252ed5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/client_lua_api.md
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/script/lua_api/l_client.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/script/lua_api/l_client.h
Expand Up @@ -66,6 +66,8 @@ class ModApiClient : public ModApiBase
// 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);

Expand Down

0 comments on commit c252ed5

Please sign in to comment.