Vixen
feb85697
csharp
public static class StringContributions

What a toolset adds to the editor's translator template when it activates.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ Five declaration classes had an All list and nothing walked it (#1202). StringFamily's whole argument is that an id built at a call site "is in no All list, so Template does not export it, so no translator's template contains it" — and the migration that answered it put the ids in an All list that no production code read. WaterStrings.All, TexturingStrings.All, TerrainStrings.All, BlockoutStrings.All and DiagnosticsStrings.All were each read by nothing at all, so every word those five toolsets say was in exactly the state the census exists to make impossible, one level up.

A registration rather than a list here, because a toolset is a plugin: the editor cannot name WaterStrings without depending on Vixen.Editor.Water, which is the dependency doc 36 § P3 spent real effort removing. A module hands its All over as it activates, the same way it hands over its panels and its commands, and an out-of-tree plugin does the identical thing with no change here.

⚠ Registering the same list twice is one registration. An All list is a static property, so the reference identifies the class; a module that is deactivated and activated again — which is what the plugins panel's Disable/Enable pair does — would otherwise export every one of its strings a second time. The catalog would survive that (it is a map) and the count a translator is quoted would not.

⚠ And one registration is a count, because a withdrawal is per activation (#1316). PluginContext.AddStrings records a Withdraw for every Declare, so two live modules sharing one All array — a host running two editors, a test suite whose fixtures run in parallel — declare it twice and withdraw it twice. Matched by reference alone, the first unload took the other's words out of the template: the Texturing suite met it as an order-dependent failure the moment its All list grew. The list is still exported once; what is counted is how many activations are standing on it.

⚠ And the level above it is now wired, which this remark used to say was not (#1229). The editor's tools.export-strings writes Template through StringCatalogYaml.Save into the project's Localization/, and EditorPreferences.Language reads one back through StringCatalogYaml.Load into Strings.Use — so a template taken after a module activates carries that module's words, and the running editor re-labels when the language changes.

Fields and properties (1)

  • public static IReadOnlyList<StringId> Declared

    Every string a toolset has contributed, in registration order.

Methods (2)

  • public static void Declare(IReadOnlyList<StringId> declarations)

    Adds a declaration class's All list to the editor's template.

  • public static bool Withdraw(IReadOnlyList<StringId> declarations)

    Takes one activation's claim on a declaration class's All list back out again.

Used by (4)

  • EditorStringsVixen.Editor.Ui
  • PluginContextVixen.Editor.Plugin
  • ServiceTestsVixen.Editor.Ui.Tests
  • StringContributionTestsVixen.Editor.Ui.Tests