|
1 | 1 | local constants = require "scripts.constants"
|
2 | 2 | local config = require "scripts.config"
|
3 | 3 | local log = require("scripts.logger").control
|
| 4 | +local cc_util = require "scripts.cc_util" |
4 | 5 | local cc_gui = require "scripts.gui"
|
5 | 6 | local cc_remote = require "scripts.remote"
|
6 | 7 | local CybersynCombinator = require "scripts.combinator"
|
@@ -50,6 +51,7 @@ script.on_configuration_changed(function(data)
|
50 | 51 | -- end
|
51 | 52 | if not cc_changes then return end
|
52 | 53 | for player_index, player in pairs(game.players) do
|
| 54 | + player.request_translation({ "gui-train.empty-train-group" }) |
53 | 55 | if player.gui.screen[cc_gui.WINDOW_ID] then
|
54 | 56 | cc_gui:close(player_index, true)
|
55 | 57 | end
|
@@ -178,6 +180,33 @@ script.on_event(defines.events.on_entity_settings_pasted, function(event)
|
178 | 180 | dest_combinator:set_section_index(CybersynCombinator.NETWORK_SECTION_ID, src_combinator:get_or_create_section(CybersynCombinator.NETWORK_SECTION_ID).index)
|
179 | 181 | end)
|
180 | 182 |
|
| 183 | +script.on_event(defines.events.on_string_translated, function(event) |
| 184 | + log:debug("on_string_translated: ", serpent.line(event)) |
| 185 | + if not event.translated then return end |
| 186 | + if not type(event.localised_string) == "table" then return end |
| 187 | + local key = event.localised_string[1] |
| 188 | + if key ~= "gui-train.empty-train-group" then return end |
| 189 | + local player_data = cc_util.get_player_data(event.player_index) |
| 190 | + if not player_data then return end |
| 191 | + if not player_data.translations then player_data.translations = {} end |
| 192 | + player_data.translations[key] = event.result |
| 193 | + log:debug("on_string_translated: ", key, " = ", event.result) |
| 194 | +end) |
| 195 | + |
| 196 | +script.on_event(defines.events.on_player_joined_game, function(event) |
| 197 | + local player = game.get_player(event.player_index) |
| 198 | + if not player then return end |
| 199 | + log:debug("Player ", event.player_index, " joined, requesting translation") |
| 200 | + player.request_translation({ "gui-train.empty-train-group" }) |
| 201 | +end) |
| 202 | + |
| 203 | +script.on_event(defines.events.on_player_locale_changed, function(event) |
| 204 | + local player = game.get_player(event.player_index) |
| 205 | + if not player then return end |
| 206 | + log:debug("Locale changed for player ", event.player_index, ", requesting translation") |
| 207 | + player.request_translation({ "gui-train.empty-train-group" }) |
| 208 | +end) |
| 209 | + |
181 | 210 | local function sort_combinator(command)
|
182 | 211 | local player = game.get_player(command.player_index)
|
183 | 212 | if not player then return end
|
|
0 commit comments