tModLoader 1.4: I can't get localization to work

dragon3025

Terrarian
This is my en_US.hjson file:
Code:
Mods: {
    ReducedGrinding: {
        ItemName: {
            MoonBall: Moon Ball
        }
        ItemTooltip: {
            MoonBall: "Advances the Moon Phase"
        }
        Config: {
            Label: {
                MoonBall: "Wizard Sells {$Mods.ReducedGrinding.ItemName.MoonBall}"
            }
        }
    }
}
and this is the line that's supposed to use the text:
Code:
DisplayName.SetDefault("{$Mods.ReducedGrinding.ItemName.MoonBall}");
It just returns what's in the quotes instead of what's in the en_US.hjson file. Someone last night said to try remove the curvy brackets, but that just gave me the text without the brackets.
 
DisplayName is a ModTranslation, SetDefault simply sets the actual string of that translation (in the code its like translations[activeCulture] = value)

You want Language.GetText for LocalizedText values; key is Mods.ModName.Category.Name.
Similarly you also have LocalizationLoader.GetOrCreateTranslation for ModTranslation. I use Language.GetText mostly
 
All looks good to me actually, maybe your en_US.hjson file isn't in the Localization folder?
 
All looks good to me actually, maybe your en_US.hjson file isn't in the Localization folder?
It was in the Localization folder. I don't remember what was wrong, but eventually I fixed it by looking at the repository for Fargo Souls. Before that, I didn't realize that keys like ItemName are automatically used.
 
Back
Top Bottom