Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LocalizedString

A serializable reference that resolves and formats a localized text value.
Read time 2 minutesLast updated 7 days ago

Definition

public class LocalizedString : LocalizedEntry<IStringEntry>, IVariable

Remarks

A LocalizedString extends LocalizedEntry<TEntry> to resolve an IStringEntry and return its formatted text. Smart entries are formatted through Smart Strings, with placeholders such as
{score}
resolved against the reference's LocalizedString.LocalVariables, and the resolved value is passed through the locale's post-processing hook before it is returned. Resolve the value with LocalizedString.GetLocalizedStringAsync, or read it synchronously with LocalizedString.GetLocalizedString once the table is loaded. Subscribe to LocalizedString.StringChanged to receive the value immediately and again whenever the selected locale changes on LocalizationSettings.
Resolve a localized string and keep a label updated as the locale changes.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizedStringResolveExample { public void Resolve() { var greeting = new LocalizedString(); greeting.SetReference("My Strings", "HELLO"); greeting.StringChanged += value => Debug.Log(value); } }}

Properties

Property

Description

LocalVariablesThe local variables that Smart String placeholders resolve against when this string is formatted.

Methods

Method

Description

GetLocalizedStringResolves the localized string synchronously when the table is cached or a synchronous provider can supply it.
GetLocalizedStringAsyncResolves the localized string asynchronously, formatting it with the given arguments.
GetSourceValueResolves this string so it can be read as a Smart String placeholder in another string.
RefreshStringRe-resolves the value and pushes the result to subscribers.

Events

Member

Description

StringChangedOccurs when the resolved string value changes, and once immediately when a handler subscribes.

Delegates

Delegate

Description

LocalizedString.ChangeHandlerRepresents a method that receives a resolved localized string value.

Inheritance