mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-28 06:49:29 -04:00
Load the merged Strings catalog on FireRed boots
Game and Game2 hand the merged mod data to Strings.load right after the mod merge, so a translation mod's strings registry is what Strings() answers from. Game3:_loadMods did not: on a FireRed boot Strings() kept the catalog the launcher preloaded, which is every enabled mod's lang/strings.lua whatever game it targets, with no defined precedence, and never a registration made from mod code. Call Strings.load(self.data) after the merge, as the other two games do.
This commit is contained in:
@@ -223,6 +223,11 @@ function Game3:_loadMods(opts)
|
||||
require("src.core.Logger").error(
|
||||
"mods failed to load, continuing without them: %s", tostring(loader))
|
||||
end
|
||||
-- After the merge, so a translation mod's catalog is what Strings() reads,
|
||||
-- as Game (src/core/Game.lua) and Game2 do. Without it the catalog the
|
||||
-- launcher preloaded (every enabled mod's lang/strings.lua, whatever game
|
||||
-- it targets) stayed in place for the whole FireRed session.
|
||||
require("src.core.Strings").load(self.data)
|
||||
local okC, Gen3Compat = pcall(require, "src.mods.Gen3Compat")
|
||||
if okC and type(Gen3Compat) == "table" and Gen3Compat.applyMerged then
|
||||
local okA, err = pcall(Gen3Compat.applyMerged, self)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env luajit
|
||||
-- Game3 hands the merged mod data to Strings.load, like Game and Game2, so a
|
||||
-- translation mod's `strings` registry is what Strings() answers from.
|
||||
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
love = require("tests.love_stub")
|
||||
|
||||
local failed = 0
|
||||
local function check(cond, msg)
|
||||
if not cond then
|
||||
failed = failed + 1
|
||||
print("[FAIL] " .. msg)
|
||||
end
|
||||
end
|
||||
|
||||
local merged = { YES = "OUI" }
|
||||
package.loaded["src.mods.Loader"] = {
|
||||
new = function()
|
||||
return {
|
||||
load = function(_, data) data.strings = merged end,
|
||||
status = function() return {} end,
|
||||
}
|
||||
end,
|
||||
}
|
||||
package.loaded["src.mods.Gen3Compat"] = { applyMerged = function() end }
|
||||
|
||||
local Strings = require("src.core.Strings")
|
||||
Strings.load({ strings = { YES = "LAUNCHER" } }) -- the launcher's preload
|
||||
local Game3 = require("src.core.Game3")
|
||||
local game = { data = {} }
|
||||
Game3._loadMods(game, {})
|
||||
|
||||
check(Strings("YES") == "OUI", "Strings() answers from the merged catalog after mods load")
|
||||
check(Strings("NO") == "NO", "an untranslated key still falls back to English")
|
||||
|
||||
print(("game3_strings_catalog_test: %s (%d failed)"):format(failed == 0 and "PASS" or "FAIL", failed))
|
||||
if failed > 0 then os.exit(1) end
|
||||
Reference in New Issue
Block a user