Table of Contents

Class TranslateDictionary

Namespace
SunamoLang.SunamoXlf
Assembly
SunamoLang.dll

Dictionary for translation key-value pairs with automatic reloading capability.

public class TranslateDictionary : IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable
Inheritance
TranslateDictionary
Implements
Inherited Members
Extension Methods

Constructors

TranslateDictionary(Langs)

Initializes a new instance of the TranslateDictionary class.

public TranslateDictionary(Langs language)

Parameters

language Langs

The language for this dictionary.

Properties

BasePathSolution

Gets or sets the base path to the solution folder.

public static string? BasePathSolution { get; set; }

Property Value

string

Count

Gets the number of key-value pairs in the dictionary.

public int Count { get; }

Property Value

int

IsReadOnly

Gets a value indicating whether the dictionary is read-only.

public bool IsReadOnly { get; }

Property Value

bool

this[string]

Gets or sets the translation for the specified key.

public string this[string key] { get; set; }

Parameters

key string

The translation key.

Property Value

string

The translated string.

Keys

Gets the collection of keys in the dictionary.

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

LocalizationLanguages

Gets or sets the localization languages configuration.

public static LocalizationLanguages? LocalizationLanguages { get; set; }

Property Value

LocalizationLanguages

ReloadIfKeyWontBeFound

Gets or sets the function to reload translations when a key is not found.

public static Func<string, LocalizationLanguages, string>? ReloadIfKeyWontBeFound { get; set; }

Property Value

Func<string, LocalizationLanguages, string>

ReturnXlfKey

Gets or sets whether to return the XLF key itself instead of the translated value.

public static bool ReturnXlfKey { get; set; }

Property Value

bool

ShowMb

Gets or sets the message box display action.

public static Action<string>? ShowMb { get; set; }

Property Value

Action<string>

Values

Gets the collection of values in the dictionary.

public ICollection<string> Values { get; }

Property Value

ICollection<string>

Methods

Add(KeyValuePair<string, string>)

Adds a key-value pair to the dictionary.

public void Add(KeyValuePair<string, string> item)

Parameters

item KeyValuePair<string, string>

The key-value pair to add.

Add(string, string)

Adds a key-value pair to the dictionary.

public void Add(string key, string value)

Parameters

key string

The translation key.

value string

The translated string.

Clear()

Removes all key-value pairs from the dictionary.

public void Clear()

Contains(KeyValuePair<string, string>)

Determines whether the dictionary contains a specific key-value pair.

public bool Contains(KeyValuePair<string, string> item)

Parameters

item KeyValuePair<string, string>

The key-value pair to locate.

Returns

bool

True if the dictionary contains the key; otherwise, false.

ContainsKey(string)

Determines whether the dictionary contains the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key to locate in the dictionary.

Returns

bool

True if the dictionary contains the key; otherwise, false.

CopyTo(KeyValuePair<string, string>[], int)

Copies the elements to an array starting at the specified index.

public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)

Parameters

array KeyValuePair<string, string>[]

The target array.

arrayIndex int

The starting index.

GetEnumerator()

Returns an enumerator that iterates through the dictionary.

public IEnumerator<KeyValuePair<string, string>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, string>>

An enumerator for the dictionary.

Remove(KeyValuePair<string, string>)

Removes the specified key-value pair from the dictionary.

public bool Remove(KeyValuePair<string, string> item)

Parameters

item KeyValuePair<string, string>

The key-value pair to remove.

Returns

bool

True if the entry was removed; otherwise, false.

Remove(string)

Removes the entry with the specified key from the dictionary.

public bool Remove(string key)

Parameters

key string

The key of the entry to remove.

Returns

bool

True if the entry was removed; otherwise, false.

TryGetValue(string, out string)

Gets the value associated with the specified key.

public bool TryGetValue(string key, out string value)

Parameters

key string

The key to locate in the dictionary.

value string

When this method returns, contains the value associated with the key, if found; otherwise, null.

Returns

bool

True if the dictionary contains an entry with the specified key; otherwise, false.