fix error when loading corrupted translation files

This commit is contained in:
Jesse Plamondon-Willard 2021-09-08 19:01:40 -04:00
parent c5b8cd6264
commit a9fcbc686d
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,10 @@
← [README](README.md) ← [README](README.md)
# Release notes # Release notes
## Upcoming release
* For players:
* Fixed crash loading mods if they have corrupted translation files.
## 3.12.6 ## 3.12.6
Released 03 September 2021 for Stardew Valley 1.5.4 or later. Released 03 September 2021 for Stardew Valley 1.5.4 or later.

View File

@ -1891,9 +1891,9 @@ namespace StardewModdingAPI.Framework
string locale = Path.GetFileNameWithoutExtension(file.Name.ToLower().Trim()); string locale = Path.GetFileNameWithoutExtension(file.Name.ToLower().Trim());
try try
{ {
if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary<string, string> data)) if (!jsonHelper.ReadJsonFileIfExists(file.FullName, out IDictionary<string, string> data) || data == null)
{ {
errors.Add($"{file.Name} file couldn't be read"); // should never happen, since we're iterating files that exist errors.Add($"{file.Name} file couldn't be read"); // mainly happens when the file is corrupted or empty
continue; continue;
} }