Ludeon Forums

RimWorld => Bugs => Topic started by: Elevator on December 22, 2017, 06:26:57 PM

Title: Tooltip and main description template strings are not localizable
Post by: Elevator on December 22, 2017, 06:26:57 PM
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.
Title: Re: Tooltip and main description template strings are not localizable
Post by: Tynan on September 14, 2018, 03:35:56 AM
bump
Title: Re: Tooltip and main description template strings are not localizable
Post by: Elevator on November 12, 2018, 10:10:48 AM
The issue is still actual. I can provide a list of places in code that make translation difficult.
Title: Re: Tooltip and main description template strings are not localizable
Post by: Kenneth on November 30, 2018, 10:32:47 AM
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).
Title: Re: Tooltip and main description template strings are not localizable
Post by: Elevator on December 01, 2018, 09:01:11 AM
I had a conversation with another developer, Piotr (ison), about such places with formatting issues. I have listed several cases:
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.
Title: Re: Tooltip and main description template strings are not localizable
Post by: Elevator on December 02, 2018, 05:20:33 PM
CompNeurotrainer.TransformLabel() also generates an incorrect phrase in Russian.
Title: Re: Tooltip and main description template strings are not localizable
Post by: ison on December 06, 2018, 07:59:20 AM
Moved to mantis along with other translation issues: https://ludeon.com/mantis/view.php?id=3630