summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-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);