Using .Tr()

Syntax

string result = key.Tr(tableName);

Parameters

  • key (string): The translation key (e.g., "menu.title")

  • tableName (string, optional): The localization table name

Return Type

.Tr() returns a TrStringTask which has implicit conversion to string.

Examples

With Table Name

string title = "menu.title".Tr("UI");
string description = "item.apple.desc".Tr("Items");

Without Table Name

// Uses default table (if configured)
string text = "common.ok".Tr();

Implicit Conversion

The task automatically converts to string when assigned:

Explicit Value Access

For more control, access .value property:

Chaining with Other Methods

Since .Tr() returns a task, you can chain additional operations:

Performance Notes

  • The first access resolves and caches the value

  • Subsequent accesses return the cached result

  • Create the task once and reuse when possible

Common Patterns

UI Text Assignment

Dynamic Content

Conditional Text

Last updated