summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Program.cs12
2 files changed, 11 insertions, 2 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index bbf04556..0fd6801e 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -53,6 +53,7 @@
* Fixed assets loaded by temporary content managers not being editable by mods.
* Fixed assets not reloaded consistently when the player switches language.
* Fixed error if a mod loads a PNG while the game is loading (e.g. custom map tilesheets via `IAssetLoader`).
+ * Fixed error if a mod translation file is empty.
* Fixed input suppression not working consistently for clicks.
* Fixed console command input not saved to the log.
* Fixed `Context.IsPlayerFree` being false during festivals.
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index c9266c69..24bf0d59 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -1143,8 +1143,17 @@ namespace StardewModdingAPI
}
// validate translations
- foreach (string locale in translations.Keys)
+ foreach (string locale in translations.Keys.ToArray())
{
+ // skip empty files
+ if (translations[locale] == null || !translations[locale].Keys.Any())
+ {
+ metadata.LogAsMod($"Mod's i18n/{locale}.json is empty and will be ignored.", LogLevel.Warn);
+ translations.Remove(locale);
+ continue;
+ }
+
+ // handle duplicates
HashSet<string> keys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
HashSet<string> duplicateKeys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
foreach (string key in translations[locale].Keys.ToArray())
@@ -1155,7 +1164,6 @@ namespace StardewModdingAPI
translations[locale].Remove(key);
}
}
-
if (duplicateKeys.Any())
metadata.LogAsMod($"Mod's i18n/{locale}.json has duplicate translation keys: [{string.Join(", ", duplicateKeys)}]. Keys are case-insensitive.", LogLevel.Warn);
}