Table of Contents

Class LocalizableStringCollection

Namespace
NanoByte.Common.Collections
Assembly
NanoByte.Common.dll

A collection of LocalizableStrings with language-search methods.

[Serializable]
public class LocalizableStringCollection : List<LocalizableString>, ICloneable<LocalizableStringCollection>
Inheritance
LocalizableStringCollection
Implements
Extension Methods

Methods

Add(string)

Adds a new en string to the collection.

public void Add(string value)

Parameters

value string

The actual string value to store.

Add(string, string?)

Adds a new string with an associated language to the collection.

public void Add(string language, string? value)

Parameters

language string

The language of the value.

value string

The actual string value to store.

Clone()

Creates a deep copy of this LocalizableStringCollection (elements are cloned).

public LocalizableStringCollection Clone()

Returns

LocalizableStringCollection

The cloned LocalizableStringCollection.

ContainsExactLanguage(CultureInfo)

Checks if the collection contains an entry exactly matching the specified language.

public bool ContainsExactLanguage(CultureInfo language)

Parameters

language CultureInfo

The exact language to look for.

Returns

bool

true if an element with the specified language exists in the collection; false otherwise.

See Also

GetBestLanguage(CultureInfo)

Returns the best-fitting string in the collection for the specified language.

public string? GetBestLanguage(CultureInfo language)

Parameters

language CultureInfo

The language to look for.

Returns

string

The best-fitting string value found in the collection; null if the collection is empty.

Remarks

Language preferences in decreasing order:

  1. exact match
  2. same language with neutral culture
  3. en
  4. en-US
  5. first entry in collection

GetExactLanguage(CultureInfo)

Returns the first string in the collection exactly matching the specified language.

public string? GetExactLanguage(CultureInfo language)

Parameters

language CultureInfo

The exact language to look for.

Returns

string

The string value found in the collection; null if none was found.

See Also

Set(CultureInfo, string?)

Adds a new string with an associated language to the collection. Preexisting entries with the same language are removed.

public void Set(CultureInfo language, string? value)

Parameters

language CultureInfo

The language of the value.

value string

The actual string value to store; null to remove existing entries.