Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetLocalizedString(TableReference, TableEntryReference, Locale, object[], bool, IVariableGroup)

Resolves a localized string synchronously, or null when it cannot be resolved without an asynchronous load.
Read time 1 minuteLast updated 12 days ago

Definition

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

GetLocalizedString(TableReference, TableEntryReference, Locale, Object[], bool, IVariableGroup)

public string GetLocalizedString(TableReference tableRef, TableEntryReference entryRef, Locale locale = null, object[] args = null, bool enableFallback = true, IVariableGroup localVariables = null)

Parameters

The reference to the table collection that holds the entry.

The reference to the string entry to resolve.

locale

The locale to resolve in; null uses the selected locale.

The Smart String arguments to format placeholders with; null when the entry takes no arguments.

enableFallback

Whether to walk the locale fallback chain when the locale has no value.

localVariables

The extra variables that Smart String placeholders resolve against, in addition to the arguments.

Returns

Type

Description

stringThe formatted localized string, or null when the table is not loaded or the entry has no value.

Remarks

This is the synchronous companion to ResourceDatabase.GetLocalizedStringAsync. It resolves from tables already cached for the locale, and otherwise loads the table through any provider that implements ISynchronousAssetProvider (direct references or a
Resources
load); a table that only a purely asynchronous provider can supply resolves to null until it is loaded. Use it on the main thread when you cannot await. Smart entries are formatted and the locale post-processing hook is applied like the async form.
Reads an already-loaded string without awaiting.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class GetLocalizedStringSyncExample { public void Run() { string label = LocalizationSettings.ResourceDatabase.GetLocalizedString("UI Text", "play-button"); if (label != null) Debug.Log(label); } }}