public sealed class StringCatalogOne language's worth of an application's strings, by id.
Remarks
A flat id-to-text map, and the flatness is the point. An id is editor.command.file.save — a dotted path that says where the string is used rather than what it says — so a translator's file is diffable, an untranslated entry is a missing key rather than an English string masquerading as a translation, and two places that happen to say "Open" can be translated differently where a language needs them to be.
⚠ A catalog holds no fallbacks. The English text lives beside the id at the declaration — see StringId — so a catalog that is missing an entry falls back to something that is in the source rather than to another file that may also be missing it. This is what makes shipping with no catalog at all work, which is what the editor does today.
⚠ No file format, deliberately. A catalog is built by Set and read by Find, and how it got there is the application's business: the editor reads YAML through StringCatalogYaml, and an application publishing NativeAOT is free to read JSON through a source-generated reader instead. Attaching a parser here would put a serialiser in the package closure of every application that shows a word, including the ones that never load a catalog at all.
Fields and properties (4)
public string LanguageWhich language this is, as a BCP-47 tag.
public int CountHow many strings it has.
public IReadOnlyCollection<string> IdsThe ids it holds, in no particular order.
public static StringCatalog SourceThe catalog used when nothing has been loaded: empty, so every string falls back.
Methods (3)
public StringCatalog(string language)Creates an empty catalog for a language.
public StringCatalog Set(string id, string text)Adds or replaces a string.
public string? Find(string id)What a string says here, or null if this language does not have it.
Used by (14)
- AccessibleNameLocalisationTestsVixen.Ui.Controls.Advanced.Tests
- AccessibleNameLocalisationTestsVixen.Ui.Controls.Tests
- LocalisationTestsVixen.Ui.Controls.Tests
- StringFamilyTestsVixen.Ui.Tests
- StringsVixen.Ui
- EditorApplicationVixen.Editor.App
- EditorShellTestsVixen.Editor.Ui.Tests
- EditorStringsVixen.Editor.Ui
- MenuPresenterVixen.Editor.Ui
- ServiceTestsVixen.Editor.Ui.Tests
- StringCatalogChainTestsVixen.Editor.App.Tests
- StringCatalogYamlVixen.Editor.Ui
- StringContributionTestsVixen.Editor.Ui.Tests
- StringContributionTestsVixen.Editor.Texturing.Tests