diff options
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r-- | src/SMAPI/Events/IContentEvents.cs | 4 | ||||
-rw-r--r-- | src/SMAPI/Events/LocaleChangedEventArgs.cs | 45 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index abbaaf33..d537db70 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -19,5 +19,9 @@ namespace StardewModdingAPI.Events /// <summary>Raised after an asset is loaded by the content pipeline, after all mod edits specified via <see cref="AssetRequested"/> have been applied.</summary> /// <remarks>This event is only raised if something requested the asset from the content pipeline. Invalidating an asset from the content cache won't necessarily reload it automatically.</remarks> event EventHandler<AssetReadyEventArgs> AssetReady; + + /// <summary>Raised after the game language changes.</summary> + /// <remarks>For non-English players, this may be raised during startup when the game switches to the previously selected language.</remarks> + event EventHandler<LocaleChangedEventArgs> LocaleChanged; } } diff --git a/src/SMAPI/Events/LocaleChangedEventArgs.cs b/src/SMAPI/Events/LocaleChangedEventArgs.cs new file mode 100644 index 00000000..09d3f6e5 --- /dev/null +++ b/src/SMAPI/Events/LocaleChangedEventArgs.cs @@ -0,0 +1,45 @@ +using System; +using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode; + +namespace StardewModdingAPI.Events +{ + /// <summary>Event arguments for an <see cref="IContentEvents.LocaleChanged"/> event.</summary> + public class LocaleChangedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// <summary>The previous language enum value.</summary> + /// <remarks>For a custom language, this is always <see cref="LanguageCode.mod"/>.</remarks> + public LanguageCode OldLanguage { get; } + + /// <summary>The previous locale code.</summary> + /// <remarks>This is the locale code as it appears in asset names, like <c>fr-FR</c> in <c>Maps/springobjects.fr-FR</c>. The locale code for English is an empty string.</remarks> + public string OldLocale { get; } + + /// <summary>The new language enum value.</summary> + /// <remarks><inheritdoc cref="OldLanguage" select="remarks" /></remarks> + public LanguageCode NewLanguage { get; } + + /// <summary>The new locale code.</summary> + /// <remarks><inheritdoc cref="OldLocale" select="remarks" /></remarks> + public string NewLocale { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="oldLanguage">The previous language enum value.</param> + /// <param name="oldLocale">The previous locale code.</param> + /// <param name="newLanguage">The new language enum value.</param> + /// <param name="newLocale">The new locale code.</param> + internal LocaleChangedEventArgs(LanguageCode oldLanguage, string oldLocale, LanguageCode newLanguage, string newLocale) + { + this.OldLanguage = oldLanguage; + this.OldLocale = oldLocale; + this.NewLanguage = newLanguage; + this.NewLocale = newLocale; + } + } +} |