Class FallbackLocaleGenerationEvent
- Namespace
- MonkeyLoader.Resonite.Locale
- Assembly
- MonkeyLoader.Resonite.Integration.dll
Represents the event data for the Fallback Locale Generation Event.
public sealed class FallbackLocaleGenerationEvent : AsyncEvent
- Inheritance
-
FallbackLocaleGenerationEvent
- Inherited Members
Remarks
This event can be used by Monkeys that make use of locale keys to inject programmatically generated keys, if they haven't been defined previously.
Properties
Messages
Gets all currently known message keys with their associated messages.
public IEnumerable<KeyValuePair<string, LocaleResource.Message>> Messages { get; }
Property Value
- IEnumerable<KeyValuePair<string, LocaleResource.Message>>
Methods
AddMessage(string, string)
Adds the given message for the key if there's no message associated with it yet.
public bool AddMessage(string key, string message)
Parameters
Returns
- bool
true
if the message was newly assigned; otherwise,false
.
FormatMessage(string)
Formats the message pattern associated with the given key
without any arguments.
public string? FormatMessage(string key)
Parameters
key
stringThe key to format the message for.
Returns
FormatMessage(string, Dictionary<string, object>)
Formats the message pattern associated with the given key
using the provided arguments
for its variables.
public string? FormatMessage(string key, Dictionary<string, object> arguments)
Parameters
key
stringThe key to format the message for.
arguments
Dictionary<string, object>The arguments to use for the message pattern's variables.
Returns
FormatMessage(string, string, object)
Formats the message pattern associated with the given key
using the provided argument for its variables.
public string? FormatMessage(string key, string argumentName, object argument)
Parameters
Returns
GetMessage(string)
Gets the message pattern associated with the given key
.
public string GetMessage(string key)
Parameters
key
stringThe key to get the message for.
Returns
- string
The message associated with the
key
.
Exceptions
- KeyNotFoundException
When there's no message associated with the
key
.
TryFormatMessage(string, Dictionary<string, object>, out string?)
Tries to format the message pattern associated with the given key
using the provided arguments
for its variables.
public bool TryFormatMessage(string key, Dictionary<string, object> arguments, out string? formattedMessage)
Parameters
key
stringThe key to format the message for.
arguments
Dictionary<string, object>The arguments to use for the message pattern's variables.
formattedMessage
stringThe formatted message if there is one associated with the
key
; otherwise, null.
Returns
TryFormatMessage(string, string, object, out string?)
Tries to format the message pattern associated with the given key
using the provided argument for its variables.
public bool TryFormatMessage(string key, string argumentName, object argument, out string? formattedMessage)
Parameters
key
stringThe key to format the message for.
argumentName
stringThe name of the argument for formatting.
argument
objectThe value of the argument for formatting.
formattedMessage
stringThe formatted message if there is one associated with the
key
; otherwise, null.
Returns
TryFormatMessage(string, out string?)
Tries to format the message pattern associated with the given key
without any arguments.
public bool TryFormatMessage(string key, out string? formattedMessage)
Parameters
key
stringThe key to format the message for.
formattedMessage
stringThe formatted message if there is one associated with the
key
; otherwise, null.
Returns
TryGetMessage(string, out string?)
Tries to get the message pattern associated with the given key.
public bool TryGetMessage(string key, out string? message)
Parameters
Returns
- bool
true
if the key was found; otherwise,false
.