I’m trying to find out what can be done with mods and how and replayed the tutorial mods. I found that the current version of InfraSpace doesn’t load my localizations.json I put in the mod folder. So all text of mods is %justlikethis%.
I dug a bit through the source and found that the localizations are indeed not loaded anywhere. This can be patched from within the mod, but since mods and localizations are loaded before the mods can do anything, this is a little tricky and the easiest way I came up with is this:
public override void Load() {
ModPackage modPackage = DionicGame.modHandler.mods;
foreach (ModInfoFolder modInfoFolder in modPackage.modInfos)
{
string jsonText = File.ReadAllText(modInfoFolder.path + "localization.json");
modPackage.localizations.Add(jsonText);
}
Localization.Init(DionicGame.modHandler.mods);
}
This will load all mods’ localization.json
and then relead the entire localization, which is double effort because most things were loaded before. Also if any mod has this code, then all mods should have localization again. I think this can be used as a bandaid until InfraSpace itself loads the mod localization again.
Technical details for devs
The localization module relies on ModPackage’s method to get the mod localizations:
public List<string> GetLocalizations()
{
return localizations;
}
But the localizations
field is never written anywhere.This should probably be done in ReadModFiles
somehow.