Localision inconsistencies for rail items
Posted: Sat Jul 15, 2017 4:35 pm
I was trying to update the tooltip text of a item that changes.... I ran into a lot of errors trying to write to a logfile what the text should have been; I understand now why localization isn't just a local function; things like the current gui controls are saved in the save file as the current state. (wasn't getting the on gui open sort of event); but I did finally get it. However, if I get the tooltip text with a localisation expression {'entity-name.'..name} then if name is 'rail' it shows unknown key:entity-name.rail. But if I use the name from the items table it shows 'Straight Rail' Similarly this other mod I'm working with has 'scrap-rail' as the item type name, and it shows 'Curved Scrap Rails' if I get it from items['scrap-rail'].localised_name, but shows 'unknown key:entity-name.scrap-rail' if I use the localized string expression.
(I guess because with one, scrap-rail becomes straight-scrap-rail because these were collapsed?) Was a little confused because other rail types showed 'straight rail' but the junk rail showed 'curved scrap rail' but turns out the localization file had those names reversed.
For other types - transport-belt, fast-transport-belt, express-belt both ways work the same way.
(I guess because with one, scrap-rail becomes straight-scrap-rail because these were collapsed?) Was a little confused because other rail types showed 'straight rail' but the junk rail showed 'curved scrap rail' but turns out the localization file had those names reversed.
For other types - transport-belt, fast-transport-belt, express-belt both ways work the same way.
Code: Select all
local tooltip = '';
if( name ) then
-- this is how I get the localized name here... but it fails to translate 'rail' or 'scrap-rail' (from some mod)
tooltip ={'entity-name.'..name}
-- This is how the name was passed when the control was created; and works
tooltip = items[from].localised_name
end
ruleset_grid["upgrade-planner-from-" .. i].tooltip = tooltip