--- source_files: - DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportSettings/Resources/TranslateExtension.cs - DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportSettings/Resources/StringResources.Designer.cs generated_at: "2026-04-16T13:38:43.337295+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "5a446a4aa0389800" --- # Documentation: DTS.Viewer.PSDReportSettings.Resources ## 1. Purpose This module provides localization infrastructure for the PSD Report Settings UI within the DTS Viewer application. It bridges strongly-typed resource management with WPF XAML data binding. The `StringResources` class auto-generates access to localized strings (defaulting to English values such as "Envelope" and "Butterworth") for signal processing and export settings, while the `TranslateExtension` class exposes these resources directly in XAML markup. ## 2. Public Interface ### `TranslateExtension` (Class) **Namespace:** `DTS.Viewer.PSDReportSettings` **Inheritance:** `System.Windows.Markup.MarkupExtension` This class allows XAML bindings to retrieve localized strings dynamically. * **`TranslateExtension(string key)`** (Constructor) * Initializes the extension with a specific resource key to look up. * **`ProvideValue(IServiceProvider serviceProvider)`** (Method) * Returns `object` (specifically a `string`). * Looks up the string value using `StringResources.ResourceManager.GetString(_key)`. * Returns the localized string if found. * Returns `#stringnotfound#` if the key is null or empty. * Returns `#stringnotfound# [key]` (appending the key name) if the lookup fails (returns null). ### `StringResources` (Class) **Namespace:** `DTS.Viewer.PSDReportSettings.Resources` **Visibility:** `internal` This is a strongly-typed resource class generated by Visual Studio. It provides static properties to access localized strings. * **`ResourceManager`** (Property) * Returns the cached `global::System.Resources.ResourceManager` instance for this assembly. * **`Culture`** (Property) * Gets or sets the `global::System.Globalization.CultureInfo` used for resource lookups. * **Resource String Properties** (Static, read-only) * `EnvelopeHeader`: "Envelope" * `ExportPSDHeader`: "Export" * `ExportPSDtoCSV`: "Export PSD to CSV" * `ExportPSDtoPDF`: "Export PSD to PDF" * `FilterCenterFrequency`: "Center frequency" * `FilterOrder`: "Filter order" * `FilterSettingsHeader`: "Filters" * `FilterType`: "Filter type" * `FilterType_Bessel`: "Bessel" * `FilterType_Butterworth`: "Butterworth" * `FilterType_LinkwitzRiley`: "Linkwitz-Riley" * `HighPassFilter`: "High pass filter" * `Hz`: "Hz" * `LowPassFilter`: "Low pass filter" * `PSDSettingsHeader`: "PSD settings" * `ShowEnvelope`: "Show Envelope" * `WindowAveragingType`: "Averaging type" * `WindowOverlappingPercent`: "Overlapping %" * `WindowSettingsHeader`: "Window" * `WindowType`: "Window type" * `WindowWidth`: "Window width" ## 3. Invariants * **Return Type:** `TranslateExtension.ProvideValue` is decorated with `[MarkupExtensionReturnType(typeof(string))]`, guaranteeing the return object is a string. * **Null Safety:** `TranslateExtension.ProvideValue` will never return null. It guarantees a string return, defaulting to specific error constants if the key is missing. * **Key Requirement:** `TranslateExtension` requires a non-null, non-empty `key` argument in its constructor to function correctly. * **Singleton Manager:** `StringResources.ResourceManager` uses a lazy-initialization pattern to ensure only one instance of the resource manager exists. ## 4. Dependencies * **Internal Dependencies:** * `TranslateExtension` depends entirely on `StringResources.ResourceManager` to perform lookups. * **External Frameworks:** * `System.Windows.Markup`: Required for `MarkupExtension` and `IServiceProvider` (WPF). * `System.Resources`: Required for `ResourceManager`. * `System.Globalization`: Required for `CultureInfo`. * **Build Dependencies:** * `StringResources.Designer.cs` is auto-generated. It depends on a corresponding `.resx` file (likely `StringResources.resx`) existing in the project directory. ## 5. Gotchas * **Error String Format:** If a resource key is passed to `TranslateExtension` but not found in the `.resx` file, the UI will display `#stringnotfound# [key]`. This differs from the behavior when the key argument itself is null/empty (which returns just `#stringnotfound#`). * **Auto-Generated Code:** `StringResources.Designer.cs` contains a header warning that manual changes will be lost. Developers must edit the underlying `.resx` file to add or modify strings; editing this C# file directly is futile. * **Visibility Mismatch:** `StringResources` is `internal`, while `TranslateExtension` is `public`. Code outside the `DTS.Viewer.PSDReportSettings` assembly cannot access the resource strings directly via the class properties, but they can access them via the XAML extension. * **Namespace Split:** `TranslateExtension` resides in `DTS.Viewer.PSDReportSettings`, while the resources reside in `DTS.Viewer.PSDReportSettings.Resources`. This requires the `using` directive present in the source file.