Jump to content

String Tables? | Making a mod more localization-friendly


Recommended Posts

I'd like to consolidate some in-line strings for widgets and unlocks and whatnot into a localized string table that provides all the miscellaneous text that my mod might need. One, to make them easier to edit down the line if need be, and two... maybe it's a bit presumptuous and boastful of me, but I'm feeling pretty good about this campaign mod I'm working on, and I'd like to make a future potential localizer's job a bit easier. I'm English-only, and I've never written or coded for a potentially multilingual project before. I'm just a bit stumped on the exact method to add an English-version localization file for a mod and then reference it in code.

Link to comment
Share on other sites

You do something like this:

Content.AddStringTable(ID, {
    TITLE = {
    	HELLO_WORLD = "Hello world!",
    },
})
-- To call the string
print(LOC"TITLE.HELLO_WORLD")

Where ID is a unique id for the string table(don't know why that is a thing)

Some things, like card titles, have default string harvesting added, so you don't need to add another string table for that. I'm sure you'll figure it out.

Link to comment
Share on other sites

Thanks, that was the push I needed!

For anyone else who might be wondering about this in the future: To get my strings into a separate file, I made a file in my mod folder (lang/english.lua) like this:

return {
	ARINTMOD = {
		WIDGET = {
			CELLS = "BEAM CHARGES",
            CELLS_TT_TITLE = "Beam Charges",
            CELLS_TT_TEXT = "Power charges required to fire Arint's chest piece. Arint can store <b>Beam Charge</b> in her empty cells.",
            CELLS_TT_CHARGES = "{1}/{2} CHARGES AVAILABLE",
            CELLS_TT_CHARGES_TEXT = "The first time Arint takes damage each turn, gain 1 <b>Defense</b> per empty cell.\n<b>Power Surge:</b> If Arint is below 25 health at the start of your turn, gain 1 <b>Beam Charge</b> and add 1 <b>Emergency Surge</b> to your hand.",
            CELLS_TT_CHARGES_PRIMED = "<#TITLE><b>Fully Charged:</> Some cards have additional effects when all cells are charged.</>\nThe first time Arint takes damage each turn, gain 1 <b>Defense</b> per empty cell.\n<b>Power Surge:</b> If Arint is below 25 health at the start of your turn, gain 1 <b>Beam Charge</b> and add 1 <b>Emergency Surge</b> to your hand.",
            CELLS_TT_SURGE = "{1} OVERDRIVE AVAILABLE",
            CELLS_TT_SURGE_TEXT = "<#TITLE>Increases the status conditions your cards apply by 1 stack per <b>Overdrive</b>.</>\nGaining <b>Beam Charge</b> while <b>Fully Charged</> generates <b>Overdrive</>. Reduce <b>Overdrive</b> by 1 at the end of your turn.",
            CELLS_TT_MALFUNCTION = "CHARGE CELLS MALFUNCTIONING",
            CELLS_TT_MALFUNCTION_TEXT = "You will take <#PENALTY>{1} Damage</> per charged cell at the end of your turn. (<#PENALTY>{2} Total Damage</>)",
		},
	},
}

And then in my modinit OnLoad (ARINTMOD in this case is my mod alias to resolve the pathname to the file):

Content.AddStringTable( mod.id, require "ARINTMOD:lang/english" )

Then to call the strings in code, wherever I need to input a string, including in loc.format():

LOC"ARINTMOD.WIDGET.CELLS"
LOC"ARINTMOD.WIDGET.CELLS_TT_TITLE"
LOC"ARINTMOD.WIDGET.CELLS_TT_TEXT"
LOC"ARINTMOD.WIDGET.CELLS_TT_CHARGES"
LOC"ARINTMOD.WIDGET.CELLS_TT_CHARGES_TEXT"
LOC"ARINTMOD.WIDGET.CELLS_TT_CHARGES_PRIMED"
LOC"ARINTMOD.WIDGET.CELLS_TT_SURGE"
LOC"ARINTMOD.WIDGET.CELLS_TT_SURGE_TEXT"
LOC"ARINTMOD.WIDGET.CELLS_TT_MALFUNCTION"
LOC"ARINTMOD.WIDGET.CELLS_TT_MALFUNCTION_TEXT"

Works like a charm!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...