Community Forum

Problem with g_i18n:getText

Forum Overview >> Scripting

CategoryScripting
Created30.03.2020 17:18


Lorenzos (lorenzoita) 30.03.2020 17:18
Hello,
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"

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

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

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:

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


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>
Example:
-------------
<l10n>
<text name="input_DO_SOMETHING">
<en><![CDATA[foobar]]></en>
</text>
</l10n>

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

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

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


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