72 lines
5.0 KiB
Markdown
72 lines
5.0 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReport/Resources/TranslateExtension.cs
|
||
|
|
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReport/Resources/StringResources.Designer.cs
|
||
|
|
generated_at: "2026-04-16T11:03:12.267125+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "01cf0d845cbc5765"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: DTS.Viewer.PSDReport.Resources
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
This module provides localization infrastructure for the `DTS.Viewer.PSDReport` namespace. It consists of a strongly-typed resource accessor class (`StringResources`) generated from a `.resx` file, and a WPF XAML markup extension (`TranslateExtension`) that allows UI elements to bind directly to localized strings using a key. The module ensures that the report module can present user-facing text in different languages without hardcoding strings in the UI logic.
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### Class: `TranslateExtension`
|
||
|
|
**Namespace:** `DTS.Viewer.PSDReport`
|
||
|
|
**Inheritance:** `System.Windows.Markup.MarkupExtension`
|
||
|
|
|
||
|
|
This class allows XAML bindings to retrieve localized strings declaratively.
|
||
|
|
|
||
|
|
* **Constructor: `TranslateExtension(string key)`**
|
||
|
|
* Initializes the extension with the resource key to be looked up.
|
||
|
|
* **Method: `ProvideValue(IServiceProvider serviceProvider)`**
|
||
|
|
* **Return Type:** `object` (attributed to return `string`)
|
||
|
|
* **Behavior:** Looks up the provided `_key` via `StringResources.ResourceManager`. Returns the localized string if found. If the key is null or empty, it returns the constant `"#stringnotfound#"`. If the lookup fails (returns null), it returns `"#stringnotfound# "` appended with the missing key name.
|
||
|
|
|
||
|
|
### Class: `StringResources`
|
||
|
|
**Namespace:** `DTS.Viewer.PSDReport.Resources`
|
||
|
|
**Accessibility:** `internal`
|
||
|
|
|
||
|
|
This is a strongly-typed, auto-generated resource class for looking up culture-specific strings.
|
||
|
|
|
||
|
|
* **Property: `ResourceManager`** (static, `System.Resources.ResourceManager`)
|
||
|
|
* Returns the cached `ResourceManager` instance for this assembly. It is lazily initialized upon first access.
|
||
|
|
* **Property: `Culture`** (static, `System.Globalization.CultureInfo`)
|
||
|
|
* Gets or sets the current UI culture used for resource lookups. This overrides the current thread's `CurrentUICulture` for resource lookups via this class.
|
||
|
|
* **Resource Accessors** (static, `string`)
|
||
|
|
* The following properties return localized strings corresponding to their keys:
|
||
|
|
* `DataHeader` ("Data")
|
||
|
|
* `DataSelectionHeader` ("Data selection")
|
||
|
|
* `GraphsDefaultTitle` ("Graphs ")
|
||
|
|
* `ModificationsHeader` ("Modify")
|
||
|
|
* `PSDHeader` ("PSD")
|
||
|
|
* `PSDResultsHeader` ("Results")
|
||
|
|
* `PSDSettingsHeader` ("PSD Settings")
|
||
|
|
* `SettingsTitle` ("Settings")
|
||
|
|
* `TestsDefaultTitle` ("Tests ")
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
* **Fallback Behavior:** `TranslateExtension.ProvideValue` will never return `null`. It guarantees a string return, defaulting to the literal `"#stringnotfound#"` (with optional key suffix) for missing or invalid keys.
|
||
|
|
* **Auto-generation:** `StringResources` is auto-generated. Manual modifications to `StringResources.Designer.cs` will be lost upon regeneration. The source of truth is the corresponding `.resx` file.
|
||
|
|
* **Internal Visibility:** `StringResources` is marked `internal`, restricting access to within the `DTS.Viewer.PSDReport` assembly.
|
||
|
|
* **Thread Safety:** The `ResourceManager` property in `StringResources` uses a standard lazy initialization check (`object.ReferenceEquals(resourceMan, null)`). While standard for generated code, it is not strictly thread-safe in a race condition scenario (though usually harmless for resource managers).
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
* **Internal Dependencies:**
|
||
|
|
* `TranslateExtension` depends on `StringResources` (specifically `StringResources.ResourceManager`) to perform lookups.
|
||
|
|
* **External Framework Dependencies:**
|
||
|
|
* `System.Windows.Markup`: Required for `MarkupExtension` and `MarkupExtensionReturnTypeAttribute` (implies a dependency on WPF/WindowsBase).
|
||
|
|
* `System.Resources`: Required for `ResourceManager`.
|
||
|
|
* `System.Globalization`: Required for `CultureInfo`.
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
* **Dynamic vs. Strongly-typed Access:** `TranslateExtension` uses `ResourceManager.GetString` (dynamic lookup by string) rather than the strongly-typed properties (e.g., `StringResources.DataHeader`). This means typos in XAML keys will not cause compile-time errors but will result in the `"#stringnotfound#"` fallback string appearing in the UI at runtime.
|
||
|
|
* **Missing Source File:** The actual translation values (key-value pairs) reside in a `.resx` file (e.g., `StringResources.resx`) which is not included in the provided source. The default English values shown in the XML comments (e.g., "Data", "Graphs ") are the only insight into the actual content.
|
||
|
|
* **Trailing Spaces:** The default values for `GraphsDefaultTitle` ("Graphs ") and `TestsDefaultTitle` ("Tests ") appear to contain trailing spaces in the auto-generated comments. It is unclear if this is intentional or a data artifact without seeing the `.resx` file.
|