summaryrefslogtreecommitdiff
path: root/src/SMAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-22 20:26:21 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-22 20:26:21 -0500
commitddba317142b6b5cbf3efbc867d0b5bd95afcefb2 (patch)
tree818627a691257159d93b7c838dbf0ebc0bb45200 /src/SMAPI/Program.cs
parentec1e5a169828d95c6cf0c779089b25627754c894 (diff)
downloadSMAPI-ddba317142b6b5cbf3efbc867d0b5bd95afcefb2.tar.gz
SMAPI-ddba317142b6b5cbf3efbc867d0b5bd95afcefb2.tar.bz2
SMAPI-ddba317142b6b5cbf3efbc867d0b5bd95afcefb2.zip
add friendly warning when an i18n file has duplicate keys due to case-insensitivity (#448)
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r--src/SMAPI/Program.cs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index aecf5b30..e9084b2d 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -765,7 +765,7 @@ namespace StardewModdingAPI
IContentHelper packContentHelper = new ContentHelper(contentManager, packDirPath, packManifest.UniqueID, packManifest.Name, packMonitor);
return new ContentPack(packDirPath, packManifest, packContentHelper, this.JsonHelper);
}
-
+
modHelper = new ModHelper(manifest.UniqueID, metadata.DirectoryPath, jsonHelper, contentHelper, commandHelper, modRegistryHelper, reflectionHelper, translationHelper, contentPacks, CreateTransitionalContentPack, this.DeprecationManager);
}
@@ -993,6 +993,24 @@ namespace StardewModdingAPI
}
}
+ // validate translations
+ foreach (string locale in translations.Keys)
+ {
+ HashSet<string> keys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+ HashSet<string> duplicateKeys = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+ foreach (string key in translations[locale].Keys.ToArray())
+ {
+ if (!keys.Add(key))
+ {
+ duplicateKeys.Add(key);
+ 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);
+ }
+
// update translation
TranslationHelper translationHelper = (TranslationHelper)metadata.Mod.Helper.Translation;
translationHelper.SetTranslations(translations);