Scaleform::GFx::State Scaleform::GFx::Translator
class Translator : public State;
Translator class is used for international language translation of dynamic text fields. Translation is performed through the Translate virtual function which is expected to fill in a buffer with a translated string. Developers usually override Translate method of this class.
The translation interface will be used to look up dynamic text in all of the text fields. For this reason, it is often wise to differentiate translatable text fields in the SWF file from the dynamic ones by prefixing the content with a special tag, such as a '$'. If this is done, translation implementation can translate all of the prefixed strings, while leaving the non-prefixed ones unchanged.
GFx translation interface can both receive and generate HTML formatted strings. By default, HTML tags are stripped out before calling Translate, but this behavior might be changed by returning bit Cap_ReceiveHtml set from GetCaps virtual function.
Translate method receives a pointer to TranslateInfo class. This class provides data exchange between GFx core and users code. Method TranslateInfo::GetKey() returns original text in UTF-8 encoding. Methods TranslateInfo::SetResult and TranslateInfo::SetResultHtml should be used to return plain and HTML translated texts respectively. These methods exist in two versions each for Unicode (UCS-2) and for UTF-8 encodings.
class TranslatorImpl : public Translator { virtual unsigned GetCaps() const { // Kill ending new line that gets generated if HTML text field content is used to create a translation key. return Cap_StripTrailingNewLines; } virtual bool Translate(TranslateInfo* ptranslateInfo) { // Translate '$hi' into 'Hello!'. Users can perform string lookup and substitution here. const char* pkey = ptranslateInfo->GetKey(); if (pkey[0] == '$') { String key(pkey); if (pkey == "$hi") { ptranslateInfo->SetResult(L"Hello!"); } } } }; // Use class when setting up a loader or a movie view. Ptr<TranslatorImpl> ptranslator = *new TranslatorImpl(); loader.SetTranslator(ptranslator);
Class |
Description |
Provides data to and from the Translate method such as the original text, name of textfield's instance, resulting translated text. |
Data Member |
Description |
Combination of WordWrappingTypes flags. |
Enumeration |
Description |
An enumeration type defining the translation capabilities of the Translator object. | |
An enumeration that describes bits in word-wrapping mode bit mask parameter of the Translator constructor. |
Method |
Description |
Determines whether Translate implementation can process HTML strings passed by the player. | |
Specifies capabilities of the translator, such as whether it can receive and/or return HTML. | |
Determines whether support for bidirectional text is enabled or not. | |
Determines whether custom word wrapping is enabled or not. | |
Determines whether the player will strip trailing new lines from string keys passed to translate. | |
A callback that is called on bidirectional text enabled textfields. | |
A virtual method, a callback, which is invoked once a necessity of word-wrapping for any text field is determined. | |
Looks up a translation key string for translation, filling in the translated string in UTF-8/ UCS-2 format. | |
Translator constructor. |
Structure |
Description |
Provides information of the line text to be formatted. |
GFx_Loader.h