Page 1 of 1
Format Exception in Mod localization code
Posted: Wed Dec 07, 2022 5:59 pm
by DunnyOfPenwick
I'm getting a format exception when missing a key in textdatabase.txt.
~line 517 Mod.cs
Code: Select all
public string Localize(string key)
{
return TryLocalize(key) ?? string.Format(LocalizationSettings.StringDatabase.NoTranslationFoundMessage, key);
}
It doesn't like the interpolated format string.
Re: Format Exception in Mod localization code
Posted: Wed Dec 07, 2022 6:38 pm
by Jay_H
I'll move this topic to Modder Discussion.
Re: Format Exception in Mod localization code
Posted: Wed Dec 07, 2022 11:53 pm
by DunnyOfPenwick
I was a bit too brief in my problem description.
This is a bug in the base code that was exposed by a problem in my project.
Basically, I forgot to add a key to my textdatabase.txt file.
The Mod.Localize() method should have returned a 'No translation found for XXX...' string, but instead threw a Format Exception. This is a problem with the formatting string in the base code.
Re: Format Exception in Mod localization code
Posted: Thu Dec 08, 2022 11:22 am
by Jay_H
Well, this could go in Mods, Translations, or Developer... I'll send it to Developer as it sounds most fundamental
Re: Format Exception in Mod localization code
Posted: Sun Dec 11, 2022 1:50 am
by Interkarma
Unity's "LocalizationSettings.StringDatabase.NoTranslationFoundMessage" isn't setup this way, so Mod.cs shouldn't be using string.Format here.
I've replaced with a custom string that accepts key in format.
https://github.com/Interkarma/daggerfal ... 1946835f95