$LOCALIZE

From HEWIKI
Jump to: navigation, search

The $LOCALIZE system node provides game developers with the capability to retrieve localized strings at game runtime. 


Once the Localization System has been properly configured, localized strings may be requested at run-time by making calls to the $LOCALIZE system node's _GetLocalizedStringValueAsync method. Calling this method will initiate an asynchronous request to retrieve the string with the specified ID and will immediately return a unique identifier representing the transaction being made.

GREETING_STRING_ID as ID = 19
localizedStringListener as Noderef = me
transactionID as ID
transactionID = $LOCALIZE._GetLocalizedStringValueAsync(localizedStringListener, GREETING_STRING_ID)
Upon success, the requested string will be delivered via a callback (_GotLocalizedStringValueAsync) to the node specified in the original call. Upon failure, however, a callback will be made to the _GetLocalizedStringValueAsyncFailed method.
method _GotLocalizedStringValueAsync( request_id as ID, localized_string_number as Integer, localized_string_value as String )
me.SetMyGameSpecificLocalizedText(localized_string_value)
.
method _GetLocalizedStringValueAsyncFailed( request_id as ID, localized_string_number as Integer, fail_reason as String )
me.HandleMyGameSpecificLocalizedTextFailure(localized_string_number, fail_reason)
.
There are also synchronous versions of the localized string request methods. Calling the synchronous version will immediately return a localized string, but only if it is currently cached locally by the Localization System. This is never guaranteed, as strings may be loaded and unloaded at whim by the underlying C++ systems.
GREETING_STRING_ID as ID = 19
localizedString as String
if not $LOCALIZE._GetLocalizedStringValueSync(GREETING_STRING_ID, localizedString)
me.RequestLocalizedStringAsynchronouslyThisTime(GREETING_STRING_ID)
.
Upon failure, a callback will be issued to the node specified during loading of the Localization Configuration file at _GetLocalizedStringValueSyncFailed.
method _GetLocalizedStringValueSyncFailed( localized_string_number as integer, fail_reason as string )
me.HandleGameSpecificSyncStringRequestFailure(localized_string_number, fail_reason)
.
Reasons for localized string request failure include: The Localization String Table, Text Universe or Configuration File has not yet been loaded

Methods

unique method _GetLocalizedStringValueAsync( callback_node as NodeRef, localized_string_number as Integer ) as ID
unique method _GetLocalizedStringValueSync( localized_string_number as Integer, localized_string_value references String ) as Boolean
method _GotLocalizedStringValueAsync( request_id as ID, localized_string_number as Integer, localized_string_value as String )
method _GetLocalizedStringValueAsyncFailed( request_id as ID, localized_string_number as Integer, fail_reason as String )
method _GetLocalizedStringValueSyncFailed( localized_string_number as Integer, fail_reason as String )

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox