Jump to content

[beta548219] Non-static LocString in ComplexFabricator causes translation crash

  • Branch: Preview Branch Version: Windows Fixed

Localization.RegisterForTranslation() used for translations relies on LocString.CreateLocStringKeys() to find all LocString fields for translation.

CreateLocStringKeys() requires LocStrings to be static, when they are not, the game crashes with "TargetException: Non-static field requires a target" error.

Recently, beta branch added public LocString fields to ComplexFabricator for SideScreen text. Those are non-static and cause the above exception when something using ComplexFabricator class is subjected to translation attempt. The crashing issue does not appear on live branch, the fields are not there yet.

Moving new fields to STRINGS should resolve the issue


(in the logs you will see that the crash is caused by mods. However, investigating the issue shows that the crash happens only when the mod tries to translate classes that inherit from ComplexFabricator)

Steps to Reproduce

1. Go to ComplexFabricator class

2. See that there are 2 public LocString fields

  • Like 2
  • Big Ups 2

User Feedback

A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

A more flexible long term fix would be to filter the fields checked with reflection in CreateLocStringKeys to only include static fields, as other classes added by mods may want to use instance LocString values in the future.

  • Like 1
  • Big Ups 1

Share this comment

Link to comment
Share on other sites

Changed Status to Fixed

I've fixed the ComplexFabricator issue and added checks to skip non-static fields in both CreateLocStringKeys and MakeRuntimeLocStringTree. Thanks for the detailed report.

  • Like 1
  • Thanks 1
  • Health 1

Share this comment

Link to comment
Share on other sites

Seems to be fixed, my mod no longer crash on translate 

Thanks a lot!


  • Like 1

Share this comment

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...