summaryrefslogtreecommitdiff
path: root/src/SMAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-07-09 20:59:39 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-07-09 20:59:39 -0400
commitedb44cdb4011b794e45bc278c55e41af98ebf06b (patch)
treeaabb96e1a901ca57390d91074046c9bc8107defe /src/SMAPI/Program.cs
parent1fd52f8b63d2369de84b7ab8d54596d2cb597abf (diff)
downloadSMAPI-edb44cdb4011b794e45bc278c55e41af98ebf06b.tar.gz
SMAPI-edb44cdb4011b794e45bc278c55e41af98ebf06b.tar.bz2
SMAPI-edb44cdb4011b794e45bc278c55e41af98ebf06b.zip
fix error reading empty translation files
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r--src/SMAPI/Program.cs12
1 files changed, 10 insertions, 2 deletions
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);
}