--- source_files: - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Resources/TranslateExtension.cs - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/Resources/StringResources.Designer.cs generated_at: "2026-04-16T11:08:29.234915+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "46010437bced3eec" --- # Documentation: DTS.Viewer.TestModification.Resources ## 1. Purpose This module provides localization support for the `DTS.Viewer.TestModification` namespace. It consists of a strongly-typed resource wrapper class, `StringResources`, which provides compile-time access to localized strings (likely sourced from a `.resx` file), and a XAML markup extension, `TranslateExtension`, that allows WPF UI elements to bind to these localized strings declaratively. ## 2. Public Interface ### Class: `TranslateExtension` **Namespace:** `DTS.Viewer.TestModification` **Inheritance:** `System.Windows.Markup.MarkupExtension` This class allows XAML bindings to retrieve localized strings using a resource key. * **Constructor** * `public TranslateExtension(string key)`: Initializes the extension with the specific resource key to look up. * **Method** * `public override object ProvideValue(IServiceProvider serviceProvider)`: Returns the localized string associated with the `_key`. If the key is null, empty, or not found in the resource manager, it returns an error string constant. ### Class: `StringResources` **Namespace:** `DTS.Viewer.TestModification.Resources` **Accessibility:** `internal` A strongly-typed resource class auto-generated by Visual Studio. It exposes localized strings as static properties. * **Properties** * `internal static global::System.Resources.ResourceManager ResourceManager`: Returns the cached `ResourceManager` instance responsible for retrieving resources. * `internal static global::System.Globalization.CultureInfo Culture`: Gets or sets the current `CultureInfo` used for resource lookups. * **Resource String Properties (Static)** * `string CalDate`: "Cal date" * `string DataFlag`: "Data Flag:" * `string Description`: "Description:" * `string EUMultiplier`: "EU Multiplier:" * `string EUOffset`: "EU Offset:" * `string FailedToModifySensitivity`: "Failed to modify sensitivity: " * `string Filter`: "Filter:" * `string LineFit`: "Line Fit:" * `string ModifyDate`: "Modify date" * `string NonLinear`: "Non-linear" * `string PleaseLockHeader`: "To enable, please lock a single channel." * `string Preview`: "Preview" * `string ProportionalToExcitation`: "Proportional to excitation" * `string Sensitivity`: "Sensitivity:" * `string SensorCalibration`: "Sensor calibration (most recent in db)" * `string ShiftT0ms`: "Shift T₀ (ms):" * `string T0MustBeInDataset`: "Modification can not be made, T0 must be in the dataset." * `string T1ms`: "T₁ (ms):" * `string T2ms`: "T₂ (ms):" * `string Undo`: "Cancel" * `string UndoAll`: "Restore All" * `string UndoAllPrompt`: "This will revert your saved test modifications to the backup on file. Continue?" * `string UndoPrompt`: "This will undo any change(s) to this channel made before saving. Continue?" * `string UpdateDatabase`: "Update database" * `string WriteFiles`: "Write" * `string WriteFilesPrompt`: "Are you sure you want to write these changes to disk?" ## 3. Invariants * **Non-Null Return:** `TranslateExtension.ProvideValue` will never return `null`. It guarantees a string return, either the localized value or a specific error identifier. * **Error Identifier:** If a resource key is not found, the return value must contain the constant `#stringnotfound#`. If the key is null or empty, it returns exactly `#stringnotfound#`. If the key is valid but missing from resources, it returns `#stringnotfound#` followed by a space and the missing key. * **Auto-generation:** `StringResources` is marked with `GeneratedCodeAttribute`. Its members are strictly derived from the underlying resource source (e.g., `.resx`). Manual modifications to this file will be lost upon regeneration. ## 4. Dependencies * **Internal Dependencies:** * `TranslateExtension` depends on `StringResources` to perform the actual string lookup via `StringResources.ResourceManager`. * **External Dependencies:** * `System.Windows.Markup`: Required for `MarkupExtension` and `MarkupExtensionReturnTypeAttribute` (WPF specific). * `System.Resources`: Required for `ResourceManager`. * `System.Globalization`: Required for `CultureInfo`. ## 5. Gotchas * **Auto-Generated File:** `StringResources.Designer.cs` is auto-generated. Developers must edit the corresponding `.resx` file (not present in the provided source) to add or modify strings; editing this `.cs` file directly is futile as changes will be overwritten. * **Internal Visibility:** The `StringResources` class is `internal`. It cannot be accessed from outside the `DTS.Viewer.TestModification` assembly. * **Silent Failures in UI:** `TranslateExtension` does not throw exceptions for missing keys. Instead, it returns strings like `#stringnotfound# MissingKey`. This behavior aids in debugging missing translations visually in the UI but requires the developer to inspect the string content rather than catching exceptions. * **Static Culture:** The `StringResources.Culture` property is static. Changing it will affect all subsequent resource lookups within that assembly context, which implies the application is responsible for managing the UI culture lifecycle globally.