Table of Contents

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

key string

The key to assign the message to.

message string

The message to assign to the key.

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 string

The key to format the message for.

Returns

string

The formatted message if there is one associated with the key; otherwise, null.

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 string

The key to format the message for.

arguments Dictionary<string, object>

The arguments to use for the message pattern's variables.

Returns

string

The formatted message if there is one associated with the key; otherwise, null.

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

key string

The key to format the message for.

argumentName string
argument object

Returns

string

The formatted message if there is one associated with the key; otherwise, null.

GetMessage(string)

Gets the message pattern associated with the given key.

public string GetMessage(string key)

Parameters

key string

The 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 string

The key to format the message for.

arguments Dictionary<string, object>

The arguments to use for the message pattern's variables.

formattedMessage string

The formatted message if there is one associated with the key; otherwise, null.

Returns

bool

true if the message was formatted successfully; otherwise, false.

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 string

The key to format the message for.

argumentName string

The name of the argument for formatting.

argument object

The value of the argument for formatting.

formattedMessage string

The formatted message if there is one associated with the key; otherwise, null.

Returns

bool

true if the message was formatted successfully; otherwise, false.

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 string

The key to format the message for.

formattedMessage string

The formatted message if there is one associated with the key; otherwise, null.

Returns

bool

true if the message was formatted successfully; otherwise, false.

TryGetMessage(string, out string?)

Tries to get the message pattern associated with the given key.

public bool TryGetMessage(string key, out string? message)

Parameters

key string

The key to format the message for.

message string

Returns

bool

true if the key was found; otherwise, false.