Show the language of players on their user page

exp_legacy recorded each player's locale in PlayerData statistics
which nothing read. The lua side now sends one ipc event with the
player's locale when they join and when they change language, the
instance forwards it, and the controller stores it on the player
record.

The Scenario section of the user page shows the language by name with
a flag made from regional indicator symbols. Locales with a region use
it directly, the rest map to a country through a small table covering
Factorio's locale list. Arabic, Catalan, Basque, and Esperanto have no
single country and get no flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-14 22:10:31 +00:00
1 parent 6821d62c10
commit ebe7504c00
17 files changed
+155 -34

No files matched your search

@@ -1,21 +0,0 @@
--- Stores the language used to join the server
-- @data Language
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
local LocalLanguage = PlayerData.Statistics:combine("LocalLanguage")
LocalLanguage:set_default("Unknown")
LocalLanguage:set_metadata{
name = { "exp-statistics.Locale" },
tooltip = { "exp-statistics.Locale-tooltip" },
}
local function set_locale(event)
local player = game.players[event.player_index]
LocalLanguage:set(player, player.locale)
end
--- Set the players language when they join and change language
Event.add(defines.events.on_player_created, set_locale)
Event.add(defines.events.on_player_joined_game, set_locale)
Event.add(defines.events.on_player_locale_changed, set_locale)