SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

Improve error when a mod adds duplicate translations

Pathoschild opened this issue ยท 1 comments

commented

When a mod has duplicate translations, an ArgumentException is thrown which doesn't provide any info about which mod failed:

[21:21:33 ERROR SMAPI] A mod failed handling the GameEvents.InitializeInternal event:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2..ctor(IDictionary2 dictionary, IEqualityComparer1 comparer)
at StardewModdingAPI.Framework.ModHelpers.TranslationHelper.SetTranslations(IDictionary2 translations) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ModHelpers\TranslationHelper.cs:line 81 at StardewModdingAPI.Program.ReloadTranslations(IEnumerable1 mods) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 998
at StardewModdingAPI.Program.LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 847
at StardewModdingAPI.Program.InitialiseAfterGameStart() in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 373
at StardewModdingAPI.Program.b__18_5(Object sender, EventArgs e) in C:\source_Stardew\SMAPI\src\SMAPI\Program.cs:line 201
at StardewModdingAPI.Framework.InternalExtensions.SafelyRaisePlainEvent(IMonitor monitor, String name, IEnumerable`1 handlers, Object sender, EventArgs args) in C:\source_Stardew\SMAPI\src\SMAPI\Framework\InternalExtensions.cs:line 41
[21:21:33 TRACE SMAPI] Context: locale set to en.

Show a more friendly and informative error.

commented

Done in develop for the upcoming SMAPI 2.5, which will print a warning to the console instead:

[Affected Mod Name] Mod's i18n/de.json has duplicate translation keys: [default-name.CHEST]. Keys are case-insensitive.