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
languageLangsThe language for this dictionary.
Properties
BasePathSolution
Gets or sets the base path to the solution folder.
public static string? BasePathSolution { get; set; }
Property Value
Count
Gets the number of key-value pairs in the dictionary.
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the dictionary is read-only.
public bool IsReadOnly { get; }
Property Value
this[string]
Gets or sets the translation for the specified key.
public string this[string key] { get; set; }
Parameters
keystringThe translation key.
Property Value
- string
The translated string.
Keys
Gets the collection of keys in the dictionary.
public ICollection<string> Keys { get; }
Property Value
LocalizationLanguages
Gets or sets the localization languages configuration.
public static LocalizationLanguages? LocalizationLanguages { get; set; }
Property Value
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
ReturnXlfKey
Gets or sets whether to return the XLF key itself instead of the translated value.
public static bool ReturnXlfKey { get; set; }
Property Value
ShowMb
Gets or sets the message box display action.
public static Action<string>? ShowMb { get; set; }
Property Value
Values
Gets the collection of values in the dictionary.
public ICollection<string> Values { get; }
Property Value
Methods
Add(KeyValuePair<string, string>)
Adds a key-value pair to the dictionary.
public void Add(KeyValuePair<string, string> item)
Parameters
itemKeyValuePair<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
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
itemKeyValuePair<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
keystringThe 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
arrayKeyValuePair<string, string>[]The target array.
arrayIndexintThe 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
itemKeyValuePair<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
keystringThe 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
keystringThe key to locate in the dictionary.
valuestringWhen 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.