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 |
---|---|---|
Table |
tableEntryReference | A reference to the entry in the String |
Locale | locale | The Locale to use instead of the default Selected |
Fallback |
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 |
---|---|---|
Table |
tableEntryReference | A reference to the entry in the String |
IList<object> | arguments | Arguments passed to SmartFormat or String.Format. |
Locale | locale | The Locale to use instead of the default Selected |
Fallback |
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 Default
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 Unity
Declaration
public virtual string GetLocalizedString(TableReference tableReference, TableEntryReference tableEntryReference, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings, params object[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Table |
tableReference | A reference to the table to check for the string. |
Table |
tableEntryReference | A reference to the entry in the String |
Locale | locale | The Locale to use instead of the default Selected |
Fallback |
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 Unity
Declaration
public virtual string GetLocalizedString(TableReference tableReference, TableEntryReference tableEntryReference, IList<object> arguments, Locale locale = null, FallbackBehavior fallbackBehavior = FallbackBehavior.UseProjectSettings)
Parameters
Type | Name | Description |
---|---|---|
Table |
tableReference | A reference to the table to check for the string. |
Table |
tableEntryReference | A reference to the entry in the String |
IList<object> | arguments | Arguments passed to SmartFormat or String.Format. |
Locale | locale | The Locale to use instead of the default Selected |
Fallback |
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);