Im stuck with how to get a localised name of an item.
local realName = game.item_prototypes[itemName].localised_name
gives something like: "item-name.sand"
But how to get the real localised string "Sand"?
Trying to find this out for hours now

There is not one localised string, but an array of strings -- one for each language that has been localised. The game knows what locale you've selected and picks the correct string from that array (if a localisation exists).ravenbs wrote: Thu Apr 23, 2020 6:58 am Hello,
Im stuck with how to get a localised name of an item.
local realName = game.item_prototypes[itemName].localised_name
gives something like: "item-name.sand"
But how to get the real localised string "Sand"?
Trying to find this out for hours now![]()
Code: Select all
game.print({realName})
Code: Select all
script.on_event(defines.events.on_marked_for_deconstruction, function(event)
entities_marked_for_deconstruction(event)
end)
local function entities_translated(event)
if not global.translatedItems then
global.translatedItems ={}
end
local toTranslateString = event.localised_string[1]
local translatedString = event.result;
if not global.translatedItems[toTranslateString] then
global.translatedItems[toTranslateString] = translatedString
end
end
script.on_event(defines.events.on_string_translated, function(event)
entities_translated(event)
end)
Why do you need it as a string?ravenbs wrote: Thu Apr 23, 2020 8:03 am I need it in a string variable. Found no function doing this.
Code: Select all
if string.find( string.lower(stringRealName), string.lower(frame.fastfiltertext.text) ) then