Files

47 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings/Resources/TranslateExtension.cs
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings/Resources/StringResources.Designer.cs
generated_at: "2026-04-17T16:11:57.317124+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "c1490f04f3bdab0f"
---
# Resources
### Purpose
This module provides localization support for the ViewerSettings feature through a XAML markup extension and strongly-typed resource access. The `TranslateExtension` allows XAML bindings to localized strings, while `StringResources` provides compile-time-safe access to localized strings related to calibration behavior settings.
### Public Interface
**TranslateExtension** (inherits `MarkupExtension`)
- `TranslateExtension(string key)` - Constructor accepting the resource key to look up.
- `ProvideValue(IServiceProvider serviceProvider)` - Returns the localized string from `StringResources.ResourceManager.GetString(_key)`. Returns `"#stringnotfound#"` if key is null/empty, or `"#stringnotfound# " + _key` if the key is not found in resources.
**StringResources** (auto-generated)
- `ResourceManager` - Static property returning the cached `ResourceManager` instance for the `"DTS.Viewer.ViewerSettings.Resources.StringResources"` resource name.
- `Culture` - Static property for getting/setting the `CultureInfo` for resource lookups.
- `CalibrationBehavior_LinearIfAvailable` - Localized string: "Use the linear sensitivity, if available".
- `CalibrationBehavior_NonLinearIfAvailable` - Localized string: "Use the non-linear sensitivity, if available".
- `CalibrationBehavior_UseBothIfAvailable` - Localized string: "Use both sensitivities, if available, as separate channels".
- `CalibrationBehaviorText` - Localized string: "Calibration Behavior".
### Invariants
- `TranslateExtension._key` is set at construction time and cannot be changed.
- `StringResources` class is `internal` and all members are `internal`.
- The resource manager is lazily initialized on first access.
### Dependencies
**Depends on:**
- `System.Windows.Markup` (`MarkupExtension`, `MarkupExtensionReturnTypeAttribute`)
- `System.Resources` (`ResourceManager`)
- `System.Globalization` (`CultureInfo`)
**Depended on by:** Not determinable from source alone, but likely used by XAML files in the ViewerSettings module.
### Gotchas
- **Fallback string format:** When a key is not found, the returned string includes the key name appended after `"#stringnotfound# "`. This is useful for debugging but may appear in production if resources are missing.
- **Auto-generated file:** `StringResources.Designer.cs` is auto-generated and should not be manually edited. Changes should be made to the corresponding `.resx` file.
---