[A17b] Untranslatable strings in CompSchedule, CompUsable

Started by Alistaire, June 29, 2017, 05:31:27 AM

Previous topic - Next topic

Alistaire

CompProperties_Usable uses a "useLabel" instead of a "useKey", CompProperties_Schedule uses a "offMessage" instead of a "offKey":

// RimWorld.CompProperties_Usable
public string useLabel;

// RimWorld.CompProperties_Schedule
public string offMessage;


Which is then displayed as such:

// RimWorld.CompUsable
protected virtual string FloatMenuOptionLabel
{
get
{
return this.Props.useLabel;
}
}

// RimWorld.CompSchedule
public override string CompInspectStringExtra()
{
if (!this.Allowed)
{
return this.Props.offMessage;
}
return null;
}


Which means that useLabel/offMessage can not be translated into other languages.




Suggested solution

// RimWorld.CompProperties_Usable
public string useKey;

// RimWorld.CompProperties_Schedule
public string offKey;


// RimWorld.CompUsable
protected virtual string FloatMenuOptionLabel
{
get
{
return this.Props.useKey.Translate();
}
}

// RimWorld.CompSchedule
public override string CompInspectStringExtra()
{
if (!this.Allowed)
{
return this.Props.offKey.Translate();
}
return null;
}


// RimWorld1557Win\Mods\Core\Languages\English\Keyed\Misc_Gameplay.xml

  <!-- Comps -->
  <UseLabel_Neurotrainer>Use neurotrainer to learn {0}</UseLabel_Neurotrainer>
  <UseLabel_Artifact>Activate</UseLabel_Artifact>

  <OffMessage_SunLamp>Off for plant resting period</OffMessage_SunLamp>

ison

Thanks for reporting. Isn't it the same as translating defs labels? Why not just translate useLabel directly?


Alistaire

#3
Translations using "<Neurotrainer.comps.1.useLabel>" should of course work. However. When I do actually add this translation to the translation files, nothing happens - not even a warning or error. It seems this is what the major posts on "Translations" do but when you check whether this works in game or not, it actually doesn't do anything.

Easily reproducible by installing language mods, opening the game, switching language, going into a test colony with neurotrainers spawned and right-clicking them. The string is always "Use neurotrainer to learn {0}".

I've got to mention I'm running Rimworld with mods including Hugslib.




Further tests: adding "Neurotrainer.comps.2.useLabel" up to "Neurotrainer.comps.4.useLabel" have no effect either.

Further tests: same effect without any mods.

ison

I've just tested it and it seems to work fine. Are you sure there are no warnings?

I've added this to Items_Exotic.xml:
<Neurotrainer.comps.1.useLabel>TEST</Neurotrainer.comps.1.useLabel>

Alistaire

It works, I was using a folder ThingDefs_Items like the translation folders included with the game, but the folder name should be ThingDefs.

ison

Ah, yes, the folder names in /DefInjected must match def names. So no bug then, thanks for reporting though.