Merge pull request #450 from RetroRulez/feat/i18n-enabling

i18n: make more UI reachable for translation mods (Strings wraps, menu box auto-size, optional metric dex)
This commit is contained in:
bryanthaboi
2026-07-30 11:24:59 -04:00
committed by GitHub
7 changed files with 30 additions and 10 deletions
+7 -2
View File
@@ -97,8 +97,13 @@ function DexEntryMenu.render(game, def, sprite, forceOwned, trueColor)
-- feet/inches use the dex screen's /″ glyphs ("HT ???″" in
-- pokedex.asm; the tiles come from gfx/pokedex/pokedex.png via
-- engine/gfx/load_pokedex_tiles.asm)
Font.draw(Strings("HT %d%02d″", e.heightFt, e.heightIn or 0), 72, 44)
Font.draw(Strings("WT %.1flb", (e.weight or 0) / 10), 72, 54)
if e.heightM then
Font.draw((("GR. %.1fm"):format(e.heightM):gsub("(%d)%.(%d)", "%1,%2")), 64, 44)
Font.draw((("GEW. %.1fkg"):format(e.weightKg or 0):gsub("(%d)%.(%d)", "%1,%2")), 64, 54)
else
Font.draw(Strings("HT %d%02d″", e.heightFt, e.heightIn or 0), 72, 44)
Font.draw(Strings("WT %.1flb", (e.weight or 0) / 10), 72, 54)
end
end
local text = owned and e.text and game.data.text[e.text] or nil
local y = 72
+1 -1
View File
@@ -191,7 +191,7 @@ function ListMenu:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", 0, 0, 160, 144)
love.graphics.setColor(0, 0, 0, 1)
Font.draw(self.title, 8, 4)
Font.draw(Strings(self.title), 8, 4)
if #self.items == 0 then
Font.draw(Strings("Nothing here."), 16, 64)
end
+14
View File
@@ -19,6 +19,20 @@ function Menu.new(game, items, opts)
self.tx = opts.tx or 10
self.ty = opts.ty or 0
self.tw = opts.tw or 10
-- grow the box to the widest label so longer (e.g. localized) labels don't
-- overflow the frame; nudge tx left to keep the box on-screen (20 tiles).
do
local widest = 0
for _, it in ipairs(items) do
if it.label then
local n = #Font.split(it.label)
if n > widest then widest = n end
end
end
local needed = widest + 3
if needed > self.tw then self.tw = needed end
if self.tx + self.tw > 20 then self.tx = math.max(0, 20 - self.tw) end
end
self.rowStep = opts.rowStep or 2
-- maxVisible: cap the box to this many rows and scroll the rest instead
-- of growing past it (e.g. the start menu, whose row count varies with
+1 -1
View File
@@ -183,7 +183,7 @@ function NamingScreen:draw()
end
for r, row in ipairs(self:grid()) do
for c, cell in ipairs(row) do
Font.draw(cell, c * 16, 32 + r * 16)
Font.draw(Strings(cell), c * 16, 32 + r * 16)
end
end
Font.drawCode(Theme.cursor, self.col * 16 - 8, 32 + self.row * 16)
+5 -5
View File
@@ -84,7 +84,7 @@ local function rulesetName(game)
local ids = rulesetIds(game)
local id = ids[rulesetIndex(game, ids)] or game.save.options.ruleset
local record = id and rulesets[id]
return record and record.name or id or "----"
return Strings(record and record.name or id or "----")
end
-- 0-7 volume level display (0 = OFF)
@@ -120,7 +120,7 @@ local function sameRows(_, rows) return rows end
local function buildRows(game)
local rows = {
{ id = "textSpeed", label = Strings("TEXT SPEED"),
value = function(g) return SPEEDS[speedIndex(g)][2] end,
value = function(g) return Strings(SPEEDS[speedIndex(g)][2]) end,
step = function(g)
local i = speedIndex(g) % #SPEEDS + 1
g.save.options.textSpeed = SPEEDS[i][1]
@@ -128,7 +128,7 @@ local function buildRows(game)
end },
{ id = "animations", label = Strings("BATTLE ANIMATION"),
value = function(g)
return g.save.options.animations == false and "OFF" or "ON"
return g.save.options.animations == false and Strings("OFF") or Strings("ON")
end,
step = function(g)
local o = g.save.options
@@ -137,7 +137,7 @@ local function buildRows(game)
end },
{ id = "battleStyle", label = Strings("BATTLE STYLE"),
value = function(g)
return g.save.options.battleStyle == "set" and "SET" or "SHIFT"
return g.save.options.battleStyle == "set" and Strings("SET") or Strings("SHIFT")
end,
step = function(g)
local o = g.save.options
@@ -148,7 +148,7 @@ local function buildRows(game)
-- widescreen composition (src/battle/WideBattle.lua)
{ id = "battleLayout", label = Strings("BATTLE LAYOUT"),
value = function(g)
return g.save.options.battleLayout == "wide" and "WIDE" or "OG"
return g.save.options.battleLayout == "wide" and Strings("WIDE") or Strings("OG")
end,
step = function(g)
local o = g.save.options
+1 -1
View File
@@ -153,7 +153,7 @@ function SummaryMenu:draw()
}
for i, s in ipairs(stats) do
local y = 72 + (i - 1) * 16
Font.draw(s[1], 8, y)
Font.draw(Strings(s[1]), 8, y)
Font.draw(("%3d"):format(s[2]), 48, y + 8)
end