Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.39k stars 374 forks source link

Unable to detect system locale #2957

Open sgkoishi opened 1 year ago

sgkoishi commented 1 year ago

https://github.com/Pryaxis/TShock/blob/a7360b635a38b57b11236f7386ab8532d0374ce4/docs/lang.md?plain=1#L1

Theoretically TShock will detect the locale, but Terraria.Program.RunGame (orig_RunGame for OTAPI) calls LanguageManager.SetLanguage(GameCulture.DefaultCulture), which indirectly overwrite the CurrentUICulture to enUS.

Thus, the I18n.TranslationCultureInfo is always enUS if no TSHOCK_LANGUAGE, -lang or -language. https://github.com/Pryaxis/TShock/blob/a7360b635a38b57b11236f7386ab8532d0374ce4/TShockAPI/I18n.cs#L63

The call of SetLanguage happens before TShock and plugins, so the original value of CurrentUICulture is no longer available.

Some potential fix: