[1.3.3063] Hardcoded "body part source" formatting prevents correct translations

Started by nomius, July 18, 2021, 08:17:24 AM

Previous topic - Next topic

nomius

A colonist hit by a bear, for example, would end up with the following injury in the Health tab:

QuoteBite (Grizzly teeth)

For languages such as Romanian, French, Italian, Japanese, Spanish and probably others, the order in the parenthesis has to be reversed:

Quote
Mușcătură (dinți de Grizzly)
bite = mușcătură
teeth = dinți

However there doesn't seem to be a way to this. I suspect it's because of hardcoded code, more specifically in Hediff_Injury.cs, the LabelInBrackets method:

public override string LabelInBrackets
{
get
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(base.LabelInBrackets);
if (sourceHediffDef != null)
{
if (stringBuilder.Length != 0)
{
stringBuilder.Append(", ");
}
stringBuilder.Append(sourceHediffDef.label);
}
else if (source != null)
{
if (stringBuilder.Length != 0)
{
stringBuilder.Append(", ");
}
stringBuilder.Append(source.label);
if (sourceBodyPartGroup != null)
{
stringBuilder.Append(" ");
stringBuilder.Append(sourceBodyPartGroup.LabelShort);
}
}
HediffComp_GetsPermanent hediffComp_GetsPermanent = this.TryGetComp<HediffComp_GetsPermanent>();
if (hediffComp_GetsPermanent != null && hediffComp_GetsPermanent.IsPermanent && hediffComp_GetsPermanent.PainCategory != 0)
{
if (stringBuilder.Length != 0)
{
stringBuilder.Append(", ");
}
stringBuilder.Append(("PainCategory_" + hediffComp_GetsPermanent.PainCategory).Translate());
}
return stringBuilder.ToString();
}
}


More specifically this section in the second if statement:


stringBuilder.Append(source.label);
if (sourceBodyPartGroup != null)
{
stringBuilder.Append(" ");
stringBuilder.Append(sourceBodyPartGroup.LabelShort);
}


I don't know C#, but a format string (something like "{0} {1}", specifiable in the XMLs) could be used there.

Pheanox

Thanks for bringing this to my attention, I'll have the devs review this for translation assistance.