Skip to content

Add XML Translation Api#91

Open
HayashiUme wants to merge 1 commit into
All-Of-Us-Mods:devfrom
HayashiUme:dev
Open

Add XML Translation Api#91
HayashiUme wants to merge 1 commit into
All-Of-Us-Mods:devfrom
HayashiUme:dev

Conversation

@HayashiUme

Copy link
Copy Markdown

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.

QQ20260619-212716 QQ20260619-212740

Translation Flow

  1. Structured keys in XML: <string name="teleporter.name">传送者</string>
  2. Abstract class properties: public string RoleName => "teleporter.name";
  3. Reverse lookup: when a raw English string (like a ConfigEntry key "Example Bool") doesn't match any
    structured key, the system searches English dictionary values and maps back to the structured key for translation

Translation Files

  • Resources/Translations/English.xml and SChinese.xml for both MiraAPI and MiraAPI.Example
  • 13 other language stubs ready for community contributions
  • Files distributed to Application.persistentDataPath/mira_languages/{ModGuid}/ on startup, overwritten each update

Registration API

TranslationManager.Register("mira.example");

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.

@HayashiUme

Copy link
Copy Markdown
Author

To improve code cleanliness, I force push to the Pr
It now will to merge to the dev branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant