Page 1 of 1

[Genhis] [1.1.73] LuaPlayer::request_translation does not work with fallback groups

Posted: Thu Dec 01, 2022 11:10 pm
by raiguard
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

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)
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.

Re: [Genhis] [1.1.73] LuaPlayer::request_translation does not work with fallback groups

Posted: Fri Dec 02, 2022 4:54 pm
by irwinclockmeyer
Is there a way to turn off the "Translating dictionaries" dialog until this bug is fixed?

Re: [Genhis] [1.1.73] LuaPlayer::request_translation does not work with fallback groups

Posted: Sat Dec 03, 2022 10:54 am
by raiguard
The dialog is unable to be turned off by design. If it was disable-able then most players would turn it off and if something broke (like it did here), they would not have all of the information to file a proper bug report.

You can destroy the GUI window using a console command, but I can't guarantee that that will work consistently.