--- source_files: - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Resources/TranslateExtension.cs - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Resources/StringResources.Designer.cs generated_at: "2026-04-16T11:18:12.490923+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "8d340ea94a701586" --- # Documentation: DTS.Viewer.ChartOptions Resources ## 1. Purpose This module provides localization infrastructure for the `DTS.Viewer.ChartOptions` namespace. It consists of a XAML markup extension (`TranslateExtension`) enabling declarative binding to localized strings in UI layouts, and a strongly-typed resource accessor class (`StringResources`) that wraps the underlying `.resx` storage. It exists to decouple UI labels and chart-related text (e.g., "Save Chart", "Min/Max" labels) from the code logic, supporting potential multi-language deployments. ## 2. Public Interface ### Class: `TranslateExtension` **Namespace:** `DTS.Viewer.ChartOptions` **Inheritance:** `System.Windows.Markup.MarkupExtension` This class allows XAML bindings to retrieve localized strings directly. * **Constructor:** `TranslateExtension(string key)` * Initializes the extension with the resource key to be looked up. * **Method:** `public override object ProvideValue(IServiceProvider serviceProvider)` * Returns the localized string associated with `_key`. * Returns `#stringnotfound#` if the key is null or empty. * Returns `#stringnotfound# [key]` if the lookup fails (key not found in resources). ### Class: `StringResources` **Namespace:** `DTS.Viewer.ChartOptions.Resources` **Accessibility:** `internal` A strongly-typed resource class generated by Visual Studio/ResGen. It provides static properties to access string values defined in the resource file. * **Property:** `static global::System.Resources.ResourceManager ResourceManager` * Returns the cached `ResourceManager` instance for this assembly. * **Property:** `static global::System.Globalization.CultureInfo Culture` * Gets or sets the current UI culture for resource lookups. * **Resource Properties (Static Strings):** * `ChartUnitType`: Looks up "Chart Unit Type". * `FilterOptions_Title`: Looks up "Display Filter". * `LockT`: Looks up "Lock T". * `MaxT`: Looks up "Max:". * `MaxY`: Looks up "Max:". * `MinT`: Looks up "Min:". * `MinY`: Looks up "Min:". * `Range`: Looks up "Range". * `ResetAll`: Looks up "Reset All". * `ResetT`: Looks up "Reset T". * `SaveChart`: Looks up "Save Chart". * `SaveToPDF`: Looks up "Save to PDF". * `TimeUnitType`: Looks up "Time Unit Type". ## 3. Invariants * **Auto-generation:** `StringResources` is auto-generated; manual modifications to `StringResources.Designer.cs` will be overwritten if the tool regenerates the file. Changes must be made to the corresponding `.resx` file. * **Error Handling:** `TranslateExtension.ProvideValue` will never return `null`. It guarantees a string return, either the valid translation or a specific error constant. * **Key Requirement:** `TranslateExtension` requires a non-null, non-empty string key to attempt a valid lookup. ## 4. Dependencies * **Internal Dependencies:** * `TranslateExtension` depends on `DTS.Viewer.ChartOptions.Resources.StringResources` for the actual resource lookup logic. * **External Dependencies:** * `System.Windows.Markup`: Required for `MarkupExtension` and `MarkupExtensionReturnTypeAttribute` (WPF specific). * `System.Resources`: Used for `ResourceManager`. * `System.Globalization`: Used for `CultureInfo`. ## 5. Gotchas * **Missing Key Formatting:** If a resource key is passed to `TranslateExtension` but does not exist in the `.resx` file, the returned string includes the missing key name appended to the error token (e.g., `#stringnotfound# MyMissingKey`). This differs from the empty/null key behavior, which returns only the token `#stringnotfound#`. * **Duplicate Values:** The source indicates that `MaxT` and `MaxY` both map to the default value "Max:", and `MinT`/`MinY` map to "Min:". While likely intentional for localization reuse, context-specific nuances might be lost if the localization requirements for Time (T) vs Y-axis diverge in other languages. * **Internal Visibility:** The `StringResources` class is marked `internal`. It is not accessible outside the `DTS.Viewer.ChartOptions` assembly. External assemblies must rely on `TranslateExtension` (if public) or cannot access these resources directly.