Add XML Translation Api - #91
Conversation
bca3aaf to
9bc6e82
Compare
|
To improve code cleanliness, I force push to the Pr |
|
No conflicts with base branch |
|
Would be interesting if it used dynamic id building instead. Like for example: public class SomeRole : CrewmateRole, ICustomRole
{
public string IdPart => "someRole";
}and then the translation api will dynamically build translation ids as |
It would be better to change it to GetMethodName() |
I will make changes later |
Add Translation API
This PR adds a complete multi-language translation system to MiraAPI, allowing mods to register translation files and
use
.Translate()extension method anywhere.Translation Flow
<string name="teleporter.name">传送者</string>public string RoleName => "teleporter.name";"Example Bool") doesn't match anystructured key, the system searches English dictionary values and maps back to the structured key for translation
Translation Files
Resources/Translations/English.xmlandSChinese.xmlfor both MiraAPI and MiraAPI.ExampleApplication.persistentDataPath/mira_languages/{ModGuid}/on startup, overwritten each updateRegistration API
Tip
TranslationManager.Register() must be called in the plugin constructor rather than Load(), because attribute option constructors fire during the PluginLoad event before the mod's own Load() completes, causing .Translate() to miss the mod's own translations.