Modders can implement localizations into their own mods as well. Requires SiraUtil and some very basic knowledge of Zenject. Check out SiraUtil's README for more information.
Creating a Localization Sheet
Create a copy of the Polyglot Template Google Sheet, erase all the keys that are there (starting at line 7 then all the way down), and add your own instead. Do not delete any of the columns even if you don't plan on supporting that language because Polyglot expects the specific order of languages used in the sheet.
Retrieving and Using an ILocalizer Instance
You can get access to an ILocalizer instance by injecting it into a class. The example below uses constructor injection and Zenject's IInitializable interface. Note that you must use the [InjectOptional] attribute.
The ILocalizer interface is located in SiraUtil. This means you can add full localization support to your mod without having to depend on the SiraLocalizer mod.
Other Goodies
A useful extension method for strings exists in SiraUtil...
This will run the key through Polyglot, and if it does not exist for the current language, return the string in the parameter.
Shadow Localizations
When calling .AddLocalizationSheet methods you can specify a parameter called shadow. Setting this to true will make that sheet a shadow sheet, and your localizations for a specific language will not show unless another sheet exists that has localizations for that same specific language is NOT marked as a shadow sheet. This is to prevent one mod having a large number of localizations for different languages "bloating" the language selection list.
请发表评论