make craft guide search use local language (#3984)

Fix #3909

It is now possible to search in the crafting guide using both item id ("name", usually related to the English name) and translated item description (containing the displayed in-game name).

Co-authored-by: Araca <>
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3984
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: Araca <araca.prod@gmail.com>
Co-committed-by: Araca <araca.prod@gmail.com>
This commit is contained in:
Araca 2023-10-31 10:00:58 +00:00 committed by the-real-herowl
parent 4fcd1ae541
commit 35bb569ee1
1 changed files with 2 additions and 1 deletions

View File

@ -774,7 +774,7 @@ local function search(data)
for i = 1, #data.items_raw do
local item = data.items_raw[i]
local def = reg_items[item]
local desc = lower(def.description)
local desc = string.lower(M.get_translated_string(data.lang_code, def.description))
local search_in = item .. desc
local to_add
@ -838,6 +838,7 @@ local function init_data(name)
iX = sfinv_only and 8 or DEFAULT_SIZE,
items = init_items,
items_raw = init_items,
lang_code = M.get_player_information(name).lang_code or 'en',
}
end