Tooltip and main description template strings are not localizable

Started by Elevator, December 22, 2017, 06:26:57 PM

Previous topic - Next topic

Elevator

A lot of strings are hard-composed in the game code, which is not convenient for localization to other languages. For example, here is the code for tooltip generation:


StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(this.LabelCap);
string text = string.Empty;
if (this.gender != Gender.None)
{
text = this.gender.GetLabel();
}
if (!this.LabelCap.EqualsIgnoreCase(this.KindLabel))
{
if (text != string.Empty)
{
text += " ";
}
text += this.KindLabel;
}
if (text != string.Empty)
{
stringBuilder.Append(" (" + text + ")");
}
stringBuilder.AppendLine();
if (this.equipment != null && this.equipment.Primary != null)
{
stringBuilder.AppendLine(this.equipment.Primary.LabelCap);
}


The order of words is fixed, and nobody except developers can change it.
If there was a possibility to use template lines from localization, all the entries could be translated accurately.

Tynan

Tynan Sylvester - @TynanSylvester - Tynan's Blog

Elevator

The issue is still actual. I can provide a list of places in code that make translation difficult.

Kenneth

I fixed the one thing you mentioned in your first post. Thanks for reporting! ;)

If you're up to providing more infos for issues like this, please give us a list of methods that require changing (in the classname.methodname notation, so for example "Pawn.GetTooltip" - this makes it easier for us to find the place you're referring to as the disassembled code doesn't necessarily look like our original).

Elevator

I had a conversation with another developer, Piotr (ison), about such places with formatting issues. I have listed several cases:

  • HealthCardUtility.DrawOverviewTab(). The line is: "text = text + pawn.def.label + ", " + "AgeIndicator".Translate(pawn.ageTracker.AgeNumberString);")
  • Tradeable_Pawn.Label (getter)
  • Pawn.GetTooltip() (mentioned here)
  • IncidentWorker_PsychicDrone.DoConditionAndLetter()
  • Hediff_Injury.LabelInBrackets (getter)
This list is not complete. Potentially every string concatenation operation can cause translation issues. My suggestion was to move such lines to Keyed translation as template strings. Ison's argument was that in this case it will be easy for translators to make a mistake. I partially agree with that position, but nevertheless it would be much better for translation if at least templates for punctuationless phrases (e.g. "bear paw" or "male human") were localizable.

Elevator

CompNeurotrainer.TransformLabel() also generates an incorrect phrase in Russian.

ison