To enable localization you need to implement your version of Coherent::UIGT::LocalizationManager:
Next, in your HTML page add the
data-l10n-id attribute to any element you need localized:
When parsing the HTML, Coherent GT will automatically call
CustomLocalizationManager::Translate("TextForStartGame") when creating the button. Creating elements dynamically will also trigger translation, for instance:
If you need to translate text dynamically after an element has been created, you can call
var translatedText = engine.translate('TextForStartGame');
In case you need to need update all localized elements, use the
engine.reloadLocalization() method which will do precisely that by calling
engine.translate for each element.
If you need to change the language, it is up to your application to keep track of the current language and update the state of your custom LocalizationManager.
One way of achievieving this behaviour is the following:
The provided Sample_Localization project provided with the package shows how to do exactly that.
data-l10n-idattribute will be ignored.
engine.translate(text)there will return the argument with which it was called. Use
engine.reloadLocalization()to initialize any the localized elements to the their localization keys.