Table of Contents

Class TranslationUnit

Namespace
Tlumach
Assembly
Tlumach.dll

Represents a unit of translation - a unit of text (a word, a phrase, a sentence, etc.) in a translation accessible using a unique key.

This class is used in generated code except when using Avalonia, WinUI or UWP (those have own TranslationUnit classes in the corresponding assemblies).

public class TranslationUnit : BaseTranslationUnit, IDisposable
Inheritance
TranslationUnit
Implements
Derived
Inherited Members

Constructors

TranslationUnit(TranslationManager, TranslationConfiguration, bool)

Initializes a new instance of the TranslationUnit class.

For internal use. This constructor is used by UntranslatedUnit.

protected TranslationUnit(TranslationManager translationManager, TranslationConfiguration translationConfiguration, bool containsPlaceholders)

Parameters

translationManager TranslationManager

The translation manager to which the unit is bound.

translationConfiguration TranslationConfiguration

The translation configuration used to create the unit.

containsPlaceholders bool

An indicator of whether the unit contains placeholders.

TranslationUnit(TranslationManager, TranslationConfiguration, string, bool)

Initializes a new instance of the TranslationUnit class.

For internal use. This constructor is used by the code generated by Generator.

public TranslationUnit(TranslationManager translationManager, TranslationConfiguration translationConfiguration, string key, bool containsPlaceholders)

Parameters

translationManager TranslationManager

The translation manager to which the unit is bound.

translationConfiguration TranslationConfiguration

The translation configuration used to create the unit.

key string

The key of the unit.

containsPlaceholders bool

An indicator of whether the unit contains placeholders.

Properties

CacheValues

Gets or sets the indicator that tells the class that it may cache the string values without going for them to TranslationManager every time.

public static bool CacheValues { get; set; }

Property Value

bool

CurrentValue

Gets the value of the unit according to the current culture set in the associated translation manager.

public string CurrentValue { get; }

Property Value

string

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

NotifyPlaceholdersUpdated()

Notifies XAML bindings that they need to request a new value and update the controls.

public override void NotifyPlaceholdersUpdated()

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Events

OnChange

Fires when the NotifyPlaceholdersUpdated() method is called to notify listeners (mostly, XAML bindings) that they need to update.

Does not fire when the culture of the translation manager referenced by the TranslationManager property changes. If an application needs, it can subscribe to the OnCultureChanged event.

public event EventHandler<EventArgs>? OnChange

Event Type

EventHandler<EventArgs>

Operators

implicit operator string(TranslationUnit)

public static implicit operator string(TranslationUnit unit)

Parameters

unit TranslationUnit

Returns

string