66 lines
5.2 KiB
Markdown
66 lines
5.2 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-16T13:41:18.748200+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 XAML markup extension (`TranslateExtension`) that allows UI elements to bind directly to localized strings declaratively. Its role is to centralize string management and support UI globalization within the PSD Report component.
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### `TranslateExtension`
|
||
|
|
A `MarkupExtension` implementation for use in XAML binding.
|
||
|
|
|
||
|
|
* **Constructor**
|
||
|
|
* `public TranslateExtension(string key)` — Initializes the extension with the resource key to be looked up.
|
||
|
|
* **Methods**
|
||
|
|
* `public override object ProvideValue(IServiceProvider serviceProvider)` — Looks up the string resource identified by `_key`. Returns the localized string if found; otherwise, returns an error string.
|
||
|
|
|
||
|
|
### `StringResources` (Internal)
|
||
|
|
A strongly-typed resource class auto-generated by `StronglyTypedResourceBuilder`. It provides static properties to access localized strings.
|
||
|
|
|
||
|
|
* **Properties**
|
||
|
|
* `internal static global::System.Resources.ResourceManager ResourceManager` — Returns the cached `ResourceManager` instance for this assembly.
|
||
|
|
* `internal static global::System.Globalization.CultureInfo Culture` — Gets or sets the current `CultureInfo` used for resource lookups.
|
||
|
|
* `internal static string DataHeader` — Looks up a localized string (default: "Data").
|
||
|
|
* `internal static string DataSelectionHeader` — Looks up a localized string (default: "Data selection").
|
||
|
|
* `internal static string GraphsDefaultTitle` — Looks up a localized string (default: "Graphs ").
|
||
|
|
* `internal static string ModificationsHeader` — Looks up a localized string (default: "Modify").
|
||
|
|
* `internal static string PSDHeader` — Looks up a localized string (default: "PSD").
|
||
|
|
* `internal static string PSDResultsHeader` — Looks up a localized string (default: "Results").
|
||
|
|
* `internal static string PSDSettingsHeader` — Looks up a localized string (default: "PSD Settings").
|
||
|
|
* `internal static string SettingsTitle` — Looks up a localized string (default: "Settings").
|
||
|
|
* `internal static string TestsDefaultTitle` — Looks up a localized string (default: "Tests ").
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
* **Error Handling:** `TranslateExtension.ProvideValue` will never return `null`. It guarantees a string return, either the resource value or a specific error constant.
|
||
|
|
* **Error Format:** If a resource key is not found, the return value follows the format `#stringnotfound# [key]`.
|
||
|
|
* **Empty Key:** If `TranslateExtension` is initialized with a `null` or empty `key`, `ProvideValue` returns exactly `#stringnotfound#` (without the key appended).
|
||
|
|
* **Resource Manager:** `StringResources.ResourceManager` uses a lazy initialization pattern (singleton) and is thread-safe regarding the initial check (via `ReferenceEquals` check).
|
||
|
|
* **Code Generation:** `StringResources` is marked `internal` and is auto-generated; manual modifications to the designer file will be overwritten by tooling.
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
### Imports (This module depends on)
|
||
|
|
* `System` (Core runtime)
|
||
|
|
* `System.Windows.Markup` (For `MarkupExtension` and `IServiceProvider` — implies a dependency on WPF core assemblies)
|
||
|
|
* `System.Resources` (For `ResourceManager`)
|
||
|
|
* `System.Globalization` (For `CultureInfo`)
|
||
|
|
* `System.CodeDom.Compiler`, `System.Diagnostics`, `System.ComponentModel` (Used for attributes on the designer class)
|
||
|
|
|
||
|
|
### Consumers (What depends on this)
|
||
|
|
* **XAML Files:** Any XAML views within the `DTS.Viewer.PSDReport` namespace (or referencing it) that use the `{local:Translate KeyName}` syntax.
|
||
|
|
* **C# Logic:** Any code-behind within the `DTS.Viewer.PSDReport` assembly that accesses `StringResources` properties directly (e.g., `StringResources.PSDHeader`).
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
* **Silent Failure Mode:** The `TranslateExtension` does not throw exceptions for missing keys. Instead, it renders `#stringnotfound#` into the UI. Developers must visually inspect the UI or write specific tests to detect missing translations.
|
||
|
|
* **Designer File Editing:** `StringResources.Designer.cs` is auto-generated. To add or modify strings, the underlying `.resx` file must be edited, and the project regenerated. Direct edits to this file will be lost.
|
||
|
|
* **Trailing Spaces:** The default values for `GraphsDefaultTitle` ("Graphs ") and `TestsDefaultTitle` ("Tests ") contain trailing spaces. This may be intentional for UI padding but could cause issues if trimmed or compared strictly.
|
||
|
|
* **Internal Visibility:** `StringResources` is `internal`. External assemblies cannot access the resource properties directly; they must rely on the `TranslateExtension` (if the XAML context allows) or the `ResourceManager` property if exposed.
|