File tree 3 files changed +21
-9
lines changed
3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,18 @@ core.register_on_shutdown(function()
9
9
end )
10
10
local id = nil
11
11
12
- local server_info = core .get_server_info ()
13
- print (" Server version: " .. server_info .protocol_version )
14
- print (" Server ip: " .. server_info .ip )
15
- print (" Server address: " .. server_info .address )
16
- print (" Server port: " .. server_info .port )
12
+ do
13
+ local server_info = core .get_server_info ()
14
+ print (" Server version: " .. server_info .protocol_version )
15
+ print (" Server ip: " .. server_info .ip )
16
+ print (" Server address: " .. server_info .address )
17
+ print (" Server port: " .. server_info .port )
17
18
18
- print (" CSM restrictions: " .. dump (core .get_csm_restrictions ()))
19
+ print (" CSM restrictions: " .. dump (core .get_csm_restrictions ()))
20
+
21
+ local l1 , l2 = core .get_language ()
22
+ print (" Configured language: " .. l1 .. " / " .. l2 )
23
+ end
19
24
20
25
mod_channel = core .mod_channel_join (" experimental_preview" )
21
26
Original file line number Diff line number Diff line change @@ -634,7 +634,9 @@ Minetest namespace reference
634
634
the trailing separator. This is useful to load additional Lua files
635
635
contained in your mod:
636
636
e.g. `dofile(minetest.get_modpath(minetest.get_current_modname()) .. "stuff.lua")`
637
- * `minetest.get_language()`: returns the currently set gettext language.
637
+ * `minetest.get_language()`: returns two strings
638
+ * the current gettext locale
639
+ * the current language code (the same as used for client-side translations)
638
640
* `minetest.get_version()`: returns a table containing components of the
639
641
engine version. Components:
640
642
* `project`: Name of the project, eg, "Minetest"
Original file line number Diff line number Diff line change @@ -230,9 +230,14 @@ int ModApiClient::l_get_node_or_nil(lua_State *L)
230
230
231
231
int ModApiClient::l_get_language (lua_State *L)
232
232
{
233
- char *locale = setlocale (LC_ALL, " " );
233
+ char *locale = setlocale (LC_MESSAGES, NULL );
234
+ std::string lang = gettext (" LANG_CODE" );
235
+ if (lang == " LANG_CODE" )
236
+ lang = " " ;
237
+
234
238
lua_pushstring (L, locale);
235
- return 1 ;
239
+ lua_pushstring (L, lang.c_str ());
240
+ return 2 ;
236
241
}
237
242
238
243
int ModApiClient::l_get_wielded_item (lua_State *L)
You can’t perform that action at this time.
0 commit comments