ghorsington / COM3D2.i18nEx

Internationalization plug-in for COM3D2 for speed and simplicity
MIT License
28 stars 5 forks source link

i18nEx(UI) plugin doesn't work when using "Product.windowTitel" code. #9

Open lilly1987 opened 2 years ago

lilly1987 commented 2 years ago

https://cdn.discordapp.com/attachments/736350853442699284/932926197405470770/2022-01-18_18-06-55.mp4

ghorsington commented 2 years ago

Greetings!

The issue is probably caused by the plugin being run before i18nEx, which causes some getters in Product to get inlined. Once methods are inlined, i18nEx cannot patch these getters, the most crucial being Product.isJapan used in multiple places like Product.windowTitel and many other places to determine whether the game should use custom localisations.

I suggest doing either one of the following:

  1. Don't invoke Product getters in Awake. Preferably call them once the game is fully initialised, like after GameUty.Init.
  2. Add a soft BepInDependency to horse.coder.com3d2.i18nex as follows:

    [BepInDependency("horse.coder.com3d2.i18nex", BepInDependency.DependencyFlags.SoftDependency)]

    If i18nEx is present, this will cause your plugin to load after it, ensuring that important getters in Product are patched before they get inlined.