Community Forum

Problem with g_i18n:getText

Forum Overview >> Scripting

Created30.03.2020 17:18

Lorenzos (lorenzoita) 30.03.2020 17:18
I'm trying to load some translation from the modDesc with the function g_i18n:getText but apparently it doesn't work in that I constantly get "missing 'nameText' in l10n_it.xml"

g_inputBinding:setActionEventText(actionEventId, g_i18n:getText("action_GO_TO_SAVED_HEIGHT"))

<text name="action_GO_TO_SAVED_HEIGHT">
<en>Lower the equipment</en>
<it>Abbassa l'attrezzo</it>

Bilbo Beutlin (BBeutlin) 30.03.2020 19:05
The <text> tag must be enclosed in the <l10n> tag.

Lorenzos (lorenzoita) 30.03.2020 19:17
Yep, it is

Bilbo Beutlin (BBeutlin) 31.03.2020 06:31
Did you define the action properly in modDesc section <actions> ?

Lorenzos (lorenzoita) 31.03.2020 08:12
I guess:

<actionBinding action="GO_TO_SAVED_HEIGHT">
<binding device="KB_MOUSE_DEFAULT" input="KEY_lctrl KEY_KP_plus"/>

The problem occurs every time I try to use the g_i18n:getText() function, no matter which text it is. I also tried to use external l10n files but the game can't load the translations anyway.

Bilbo Beutlin (BBeutlin) 31.03.2020 17:50
For a complete modDesc structure you need also the section <action>
<text name="input_DO_SOMETHING">

<action name="DO_SOMETHING" category="VEHICLE" />

<actionBinding action="DO_SOMETHING">
<binding device="KB_MOUSE_DEFAULT" input="KEY_x" />

Then reference to the text with g_i18n:getText("input_DO_SOMETHING")

Note: Log in to post. Create a new account here.