[1.0] {0_gender} translation symbol causes System.FormatException

Started by Vectorial1024, May 18, 2019, 12:28:07 AM

Previous topic - Next topic

Vectorial1024

Translators may make use of different symbols whwn translating texts to their native languages (https://ludeon.com/forums/index.php?topic=43979.0). However, the usage of some of the symbols causes fatal errors. In my case, the usage of the {0_gender? : : } symbol/operator caused System.FormatException.

This bug was discovered by a French translation helper of one of my mods when using the symbol/operator {0_gender? : : }. It was completely unexpected to receive error messages due to translations.

This bug is especially difficult to catch because the symbol does not seem to be used often. From my knowledge, the French translation of "My cousin died" makes use of such symbol/operator.

A savefile is attached to demonstrate the bug. While I have used the mod Prepare Carefully to help reproduce the bug, it shouldn't influence the bug.

Savefile too large, so it's here: https://github.com/Vectorial1024/RW_TranslationBug

Steps to reproduce:

  • Start the game in English.
  • Load the savefile.
  • Notice that Serra and Latch are related to each other as cousins.
  • Kill one of them, and open the Needs tab of the other.
  • Notice that there are no problems; the "My cousin died" thought is among the list of thoughts.
  • Notice that, in the English localization, the {0_gender? : : } symbol/operator is not used for the "My cousin died" thought.
  • Discard changes, and restart the game in French.
  • Load the savefile.
  • Similarly, kill one of them, and open the Needs tab.
  • The "My cousin died" thought is not displayed; rather, a blank row is displayed, accompanied with a System.FormatException.
  • Notice that, in the French localization, the {0_gender? : : } symbol/operator is used for the "My cousin died" thought.

The error log will contain an entry like this:

...

Exception in DrawThoughtGroup for MyCousinDied on Latch: System.FormatException: Input string was not in a correct format.
  at System.String.ParseFormatSpecifier (System.String str, System.Int32& ptr, System.Int32& n, System.Int32& width, System.Boolean& left_align, System.String& format) [0x00000] in <filename unknown>:0
  at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
  at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
  at System.String.Format (System.String format, System.Object arg0) [0x00000] in <filename unknown>:0
  at RimWorld.Thought_Memory.get_LabelCap () [0x00000] in <filename unknown>:0
  at RimWorld.NeedsCardUtility.DrawThoughtGroup (Rect rect, RimWorld.Thought group, Verse.Pawn pawn) [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.Log:ErrorOnce(String, Int32, Boolean)
RimWorld.NeedsCardUtility:DrawThoughtGroup(Rect, Thought, Pawn)
RimWorld.NeedsCardUtility:DrawThoughtListing(Rect, Pawn, Vector2&)
RimWorld.NeedsCardUtility:DoMoodAndThoughts(Rect, Pawn, Vector2&)
RimWorld.NeedsCardUtility:DoNeedsMoodAndThoughts(Rect, Pawn, Vector2&)
RimWorld.ITab_Pawn_Needs:FillTab()
Verse.<DoTabGUI>c__AnonStorey0:<>m__0()
Verse.ImmediateWindow:DoWindowContents(Rect)
Verse.<WindowOnGUI>c__AnonStorey0:<>m__0(Int32)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, Int32, GUISkin, Int32, Single, Single, GUIStyle)
RimWorld modder, reporting for duty.
Desynchronized: Tales and News
Elite Bionics Framework
More mods of mine are on Steam. Check them out!