Class LocalizedString
A Localized String contains a reference to a StringTableEntry inside of a specific StringTable. This provides a centralized way to work with localized strings.
Inherited Members
Namespace: UnityEngine.Localization
Syntax
[Serializable]
public class LocalizedString : LocalizedReference
Properties
Arguments
Arguments that will be passed through to Smart Format. These arguments are not serialized and will need to be set during play mode.
Declaration
public object[] Arguments { get; set; }
Property Value
Type | Description |
---|---|
Object[] |
CurrentLoadingOperation
The current loading operation for the string. A string may not be immediately available,
such as when loading the StringTable, so all string operations are wrapped
with an
Declaration
public AsyncOperationHandle<LocalizedDatabase<StringTable, StringTableEntry>.TableEntryResult>? CurrentLoadingOperation { get; }
Property Value
Type | Description |
---|---|
Nullable<AsyncOperationHandle<LocalizedDatabase.TableEntryResult<>>> |
Methods
ClearChangeHandler()
Removes the handler and stops listening to changes to SelectedLocaleChanged.
Declaration
public void ClearChangeHandler()
ForceUpdate()
Declaration
protected override void ForceUpdate()
Overrides
GetLocalizedString()
This function will load the requested string table and return the translated string. The Completed event will provide notification once the operation has finished and the string has been found or an error has occurred, this will be called during LateUpdate. It is possible that a string table may have already been loaded, such as during a previous operation or when using Preload mode, the IsDone property can be checked as it is possible the translated string is immediately available.
Declaration
public AsyncOperationHandle<string> GetLocalizedString()
Returns
Type | Description |
---|---|
AsyncOperationHandle<String> |
GetLocalizedString(Object[])
Loads the requested string table and return the translated string after being formatted using the provided arguments. The Completed event will provide notification once the operation has finished and the string has been found or an error has occurred, this will be called during LateUpdate. It is possible that a string table may have already been loaded, such as during a previous operation or when using Preload mode, the IsDone property can be checked as it is possible the translated string is immediately available.
Declaration
public AsyncOperationHandle<string> GetLocalizedString(params object[] arguments)
Parameters
Type | Name | Description |
---|---|---|
Object[] | arguments | Arguments that will be passed to Smart Format or String.Format. |
Returns
Type | Description |
---|---|
AsyncOperationHandle<String> |
RefreshString()
Forces a refresh of the string when using a LocalizedString.ChangeHandler. Note, this will only only force the refresh if there is currently no loading operation, if one is still being executed then it will be ignored and false will be returned. If a string is not static and will change during game play, such as when using format arguments, then this can be used to force the string update itself.
Declaration
public bool RefreshString()
Returns
Type | Description |
---|---|
Boolean | True if a refresh was requested or false if it could not. |
RegisterChangeHandler(LocalizedString.ChangeHandler)
Register a handler that will be called whenever a localized string is available.
When a handler is registered, the string will then be automatically loaded whenever the
SelectedLocaleChanged is changed, during initialization and if
RefreshString() is called.
Declaration
public void RegisterChangeHandler(LocalizedString.ChangeHandler handler)
Parameters
Type | Name | Description |
---|---|---|
LocalizedString.ChangeHandler | handler |