Method GetLocalizedString
GetLocalizedString(TableEntryReference, Locale, FallbackBehavior, params object[])
Attempts to retrieve a string from the requested table. Uses WaitForCompletion to force the loading to complete synchronously. Please note that WaitForCompletion is not supported on WebGL.
Declaration
public string GetLocalizedString(TableEntryReference tableEntryReference, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings, params object[] arguments)
Parameters
Type | Name | Description |
---|---|---|
TableEntryReference | tableEntryReference | A reference to the entry in the StringTable |
Locale | locale | The Locale to use instead of the default SelectedLocale |
FallbackBehavior | fallbackBehavior | A Enum which determines if a Fallback should be used when no value could be found for the Locale. |
object[] | arguments | Arguments passed to SmartFormat or String.Format. |
Returns
Type | Description |
---|---|
string |
GetLocalizedString(TableEntryReference, IList<object>, Locale, FallbackBehavior)
Attempts to retrieve a string from the requested table. Uses WaitForCompletion to force the loading to complete synchronously. Please note that WaitForCompletion is not supported on WebGL.
Declaration
public string GetLocalizedString(TableEntryReference tableEntryReference, IList<object> arguments, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings)
Parameters
Type | Name | Description |
---|---|---|
TableEntryReference | tableEntryReference | A reference to the entry in the StringTable |
IList<object> | arguments | Arguments passed to SmartFormat or String.Format. |
Locale | locale | The Locale to use instead of the default SelectedLocale |
FallbackBehavior | fallbackBehavior | A Enum which determines if a Fallback should be used when no value could be found for the Locale. |
Returns
Type | Description |
---|---|
string |
Examples
This example shows how to get a localized string from the DefaultTable which uses formatting arguments and use the Completed event to display it.
var localizedString = LocalizationSettings.StringDatabase.GetLocalizedString("My Table", "My String");
Debug.Log(localizedString);
GetLocalizedString(TableReference, TableEntryReference, Locale, FallbackBehavior, params object[])
Attempts to retrieve a string from the requested table. The string will first be formatted with UnityEngine.Localization.SmartFormat if IsSmart is enabled otherwise it will use String.Format. Uses WaitForCompletion to force the loading to complete synchronously. Please note that WaitForCompletion is not supported on WebGL.
Declaration
public virtual string GetLocalizedString(TableReference tableReference, TableEntryReference tableEntryReference, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings, params object[] arguments)
Parameters
Type | Name | Description |
---|---|---|
TableReference | tableReference | A reference to the table to check for the string. |
TableEntryReference | tableEntryReference | A reference to the entry in the StringTable |
Locale | locale | The Locale to use instead of the default SelectedLocale |
FallbackBehavior | fallbackBehavior | A Enum which determines if a Fallback should be used when no value could be found for the Locale. |
object[] | arguments | Arguments passed to SmartFormat or String.Format. |
Returns
Type | Description |
---|---|
string |
Examples
This example shows how to get a localized string from a specified table and entry.
var localizedString = LocalizationSettings.StringDatabase.GetLocalizedString("My Table", "My String");
Debug.Log(localizedString);
GetLocalizedString(TableReference, TableEntryReference, IList<object>, Locale, FallbackBehavior)
Attempts to retrieve a string from the requested table. The string will first be formatted with UnityEngine.Localization.SmartFormat if IsSmart is enabled otherwise it will use String.Format. Uses WaitForCompletion to force the loading to complete synchronously. Please note that WaitForCompletion is not supported on WebGL.
Declaration
public virtual string GetLocalizedString(TableReference tableReference, TableEntryReference tableEntryReference, IList<object> arguments, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings)
Parameters
Type | Name | Description |
---|---|---|
TableReference | tableReference | A reference to the table to check for the string. |
TableEntryReference | tableEntryReference | A reference to the entry in the StringTable |
IList<object> | arguments | Arguments passed to SmartFormat or String.Format. |
Locale | locale | The Locale to use instead of the default SelectedLocale |
FallbackBehavior | fallbackBehavior | A Enum which determines if a Fallback should be used when no value could be found for the Locale. |
Returns
Type | Description |
---|---|
string |
Examples
This example shows how to get a localized string which uses Smart String for formatting.
// Prepare Smart String Arguments.
var dictionary = new Dictionary<string, string>();
dictionary.Add("title", "General");
dictionary.Add("name", "Radahn");
// Example string: "I am {title} {name}!"
var localizedString = LocalizationSettings.StringDatabase.GetLocalizedString("Main Characters", "General_Radahn_Intro", new object[] { dictionary });
// Example output: "I am General Radahn!"
Debug.Log(localizedString);