Table of Contents

Class LocalizableString

Namespace
GroupeIsa.Neos.Shared.Localization
Assembly
GroupeIsa.Neos.Shared.dll

Represents a localizable string.

[JsonConverter(typeof(LocalizableStringJsonConverter))]
public sealed class LocalizableString : IEquatable<LocalizableString>
Inheritance
LocalizableString
Implements
Inherited Members
Extension Methods

Constructors

LocalizableString()

Initializes a new instance of the LocalizableString class.

public LocalizableString()

LocalizableString(IDictionary<string, string>)

Initializes a new instance of the LocalizableString class from the specified dictionary.

public LocalizableString(IDictionary<string, string> dictionary)

Parameters

dictionary IDictionary<string, string>

The dictionary that contains the data to copy.

LocalizableString(string)

Initializes a new instance of the LocalizableString class from a single localized string.

public LocalizableString(string defaultTranslation)

Parameters

defaultTranslation string

Default localized string.

Properties

Count

Gets the number of elements.

public int Count { get; }

Property Value

int

DefaultTranslation

Gets the default translation corresponding to the default language of the cluster.

public string DefaultTranslation { get; }

Property Value

string

ExtendedProperties

Gets the extended properties used with OData query.

public IDictionary<string, object> ExtendedProperties { get; }

Property Value

IDictionary<string, object>

this[string]

Gets the translation for the specified language.

public string this[string key] { get; }

Parameters

key string

The language id.

Property Value

string

The translation.

Exceptions

KeyNotFoundException

The language id does not exist.

Keys

Gets the collection of localized string languages.

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

Values

Gets the collection of localized string values.

public ICollection<string> Values { get; }

Property Value

ICollection<string>

Methods

AsEnumerable()

Converts to enumerable.

public IEnumerable<KeyValuePair<string, string>> AsEnumerable()

Returns

IEnumerable<KeyValuePair<string, string>>

An enumerable.

Combine(LocalizableString, Func<string, string, string>)

Combines a localization string with another localizable string.

public LocalizableString Combine(LocalizableString value, Func<string, string, string> combineMethod)

Parameters

value LocalizableString

Localizable string..

combineMethod Func<string, string, string>

Combine method.

Returns

LocalizableString

The new localizable string.

ContainsKey(string)

Gets a value indicating whether the specified language is defined.

public bool ContainsKey(string language)

Parameters

language string

The language.

Returns

bool

True when the specified language is defined, False otherwise.

ConvertFromJson(string)

Converts from JSON.

public static LocalizableString ConvertFromJson(string value)

Parameters

value string

Value.

Returns

LocalizableString

A new instance of the LocalizableString class.

ConvertFromString(string)

Converts from string.

public static LocalizableString ConvertFromString(string value)

Parameters

value string

Value.

Returns

LocalizableString

A new instance of the LocalizableString class.

ConvertToJson()

Converts to JSON.

public string ConvertToJson()

Returns

string

string representation.

ConvertToString()

Converts to string.

public string ConvertToString()

Returns

string

string representation.

Equals(LocalizableString?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(LocalizableString? other)

Parameters

other LocalizableString

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromFormattedResource(ILocalizationSettings, ResourceManager, string, params object?[])

Gets a LocalizableString from a resource with a format item in each language replaced with the string representation of a corresponding object in the specified array.

public static LocalizableString FromFormattedResource(ILocalizationSettings localizationSettings, ResourceManager resourceManager, string resourceWithFormatName, params object?[] args)

Parameters

localizationSettings ILocalizationSettings

Localization settings.

resourceManager ResourceManager

Resource manager. For example Resources.MyModule.ResourceManager.

resourceWithFormatName string

Name of the resource that contains a format.

args object[]

An object array that contains zero or more objects to format.

Returns

LocalizableString

Localizable string corresponding to the resource in which the format items in each language have been replaced by the string representation of the corresponding objects in args.

FromResource(ILocalizationSettings, ResourceManager, string)

Gets a LocalizableString from a resource.

public static LocalizableString FromResource(ILocalizationSettings localizationSettings, ResourceManager resourceManager, string resourceName)

Parameters

localizationSettings ILocalizationSettings

Localization settings.

resourceManager ResourceManager

Resource manager. For example Resources.MyModule.ResourceManager.

resourceName string

Name of the resource.

Returns

LocalizableString

Localizable string corresponding to the resource.

FromString(string)

Converts a string to LocalizableString.

public static LocalizableString FromString(string defaultTranslation)

Parameters

defaultTranslation string

Default localized string.

Returns

LocalizableString

The localizable string containing the default translation.

GetAdditionalTranslations(ILocalizationSettings?)

Gets the list of translations except the default one.

public IEnumerable<KeyValuePair<string, string>> GetAdditionalTranslations(ILocalizationSettings? settings = null)

Parameters

settings ILocalizationSettings

Settings.

Returns

IEnumerable<KeyValuePair<string, string>>

The additional translations.

GetDefaultTranslation(ILocalizationSettings?)

Gets default translation.

public string GetDefaultTranslation(ILocalizationSettings? settings = null)

Parameters

settings ILocalizationSettings

Settings.

Returns

string

The default translation.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetTranslationOrDefault(string?, ILocalizationSettings?)

Gets the translation for the specified language or the default one if not found.

public string GetTranslationOrDefault(string? language = null, ILocalizationSettings? settings = null)

Parameters

language string

The language.

settings ILocalizationSettings

The settings.

Returns

string

The translation.

ToDictionary()

Converts to dictionary.

public IDictionary<string, string> ToDictionary()

Returns

IDictionary<string, string>

The dictionary.

ToString()

Gets one of the strings according to the current localization settings.

public override string ToString()

Returns

string

The localized string.

Remarks

This is the overridden version of the object.ToString method: it allows using those objects for string interpolation.

ToString(char, char)

Join strings with a delimiter and escape any occurrence of the delimiter and the escape character in the string.

public string ToString(char delimiterChar, char escapeChar = '\\')

Parameters

delimiterChar char

Delimiter.

escapeChar char

Escape character.

Returns

string

Joined string.

TryGetValue(string, out string)

Gets the value associated with the specified language.

public bool TryGetValue(string language, out string value)

Parameters

language string

The language.

value string

The text in the specified language.

Returns

bool

true if the object contains an element with the specified language; otherwise, false.

WithTranslation(string, string?)

Gets a new instance with a modified translation.

public LocalizableString WithTranslation(string language, string? value)

Parameters

language string

Language.

value string

Translation.

Returns

LocalizableString

A new instance.

Operators

implicit operator Dictionary<string, string>(LocalizableString)

Implicitly converts a LocalizableString to a dictionary.

public static implicit operator Dictionary<string, string>(LocalizableString localizableString)

Parameters

localizableString LocalizableString

The localizableString to implicitly convert.

Returns

Dictionary<string, string>

implicit operator LocalizableString(Dictionary<string, string>)

Defines an implicit conversion of a given Dictionary{string, string} to LocalizableString.

public static implicit operator LocalizableString(Dictionary<string, string> dictionary)

Parameters

dictionary Dictionary<string, string>

A array to implicitly convert.

Returns

LocalizableString

implicit operator LocalizableString(string)

Implicitly converts a string to LocalizableString.

public static implicit operator LocalizableString(string defaultTranslation)

Parameters

defaultTranslation string

Default localized string.

Returns

LocalizableString