[Genhis] [1.1.73] LuaPlayer::request_translation does not work with fallback groups
Posted: Thu Dec 01, 2022 11:10 pm
LuaPlayer::request_translation does not handle the new fallback groups format, and fails the translation if you attempt to use it.
To reproduce:
1. Copy the below code into a mod control.lua
2. Start a new game
3. Observe that the frame in the top-left correctly shows ice-cream
4. Observe the chat message notifying that the translation request failed
Also, with this update, the behavior of this function changed to fail a translation if any substring is invalid - before, it would only fail if the top-level string was invalid. However, this new behavior feels like the correct behavior, and I can work around it using fallbacks once those are fixed.
To reproduce:
1. Copy the below code into a mod control.lua
2. Start a new game
3. Observe that the frame in the top-left correctly shows ice-cream
4. Observe the chat message notifying that the translation request failed
Code: Select all
local string = { "?", { "item-name.ice-cream" }, "ice-cream" }
script.on_event(defines.events.on_player_created, function(e)
local player = game.get_player(e.player_index) --[[@as LuaPlayer]]
player.gui.top.add({ type = "frame", caption = string })
player.request_translation(string)
end)
script.on_event(defines.events.on_string_translated, function(e)
if not e.translated then
game.print("Translation failed: " .. serpent.line(e.localised_string))
end
end)