Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetLocalizedStringAsync(params object[])

Resolves the localized string asynchronously, formatting it with the given arguments.
Read time 1 minuteLast updated 6 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule

GetLocalizedStringAsync(Object[])

public Awaitable<string> GetLocalizedStringAsync(params object[] args)

Parameters

Optional arguments that Smart String placeholders format against.

Returns

Type

Description

Awaitable<string>An awaitable that produces the formatted localized string, or an empty string when the reference is empty.

Remarks

Loads the table through the ResourceDatabase provider chain if needed, formats Smart String placeholders against the supplied arguments and LocalizedString.LocalVariables, and returns an empty string when the reference is empty. When LocalizationSettings.PreferredLoading is LoadingPreference.Synchronous, it resolves synchronously when the value is available and otherwise falls back to this asynchronous load.
Resolve a string and format it with an argument.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class LocalizedStringFormatAsyncExample { public async Awaitable Resolve() { var localizedString = new LocalizedString(); localizedString.SetReference("My Strings", "GREETING"); string playerName = "Sam"; string text = await localizedString.GetLocalizedStringAsync(playerName); Debug.Log(text); } }}