4.7 KiB
4.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T13:50:32.426485+00:00 | zai-org/GLM-5-FP8 | 1 | b58f3ee343f377b9 |
Documentation: DTS.Viewer.ViewerSettings.Resources
1. Purpose
This module provides localization infrastructure for the DTS.Viewer.ViewerSettings 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 using the resource keys. This separates user-facing text from code logic and supports multi-language deployments.
2. Public Interface
TranslateExtension
Location: DTS.Viewer.ViewerSettings
Inheritance: System.Windows.Markup.MarkupExtension
A XAML markup extension used to resolve localized strings in the UI layer.
TranslateExtension(string key)- Constructor that accepts the resource key to be translated.
object ProvideValue(IServiceProvider serviceProvider)- Returns the localized string corresponding to the
_key. - Returns
#stringnotfound#if the key is null or empty. - Returns
#stringnotfound# {key}if the lookup fails for a specific key.
- Returns the localized string corresponding to the
StringResources
Location: DTS.Viewer.ViewerSettings.Resources
Attributes: internal, Auto-generated
A strongly-typed resource class providing access to localized strings.
static global::System.Resources.ResourceManager ResourceManager- Returns the cached
ResourceManagerinstance for this assembly.
- Returns the cached
static global::System.Globalization.CultureInfo Culture- Gets or sets the
CultureInfoused for resource lookups. Overrides the current thread'sCurrentUICulture.
- Gets or sets the
static string CalibrationBehavior_LinearIfAvailable- Resource string: "Use the linear sensitivity, if available."
static string CalibrationBehavior_NonLinearIfAvailable- Resource string: "Use the non-linear sensitivity, if available."
static string CalibrationBehavior_UseBothIfAvailable- Resource string: "Use both sensitivities, if available, as separate channels."
static string CalibrationBehaviorText- Resource string: "Calibration Behavior".
3. Invariants
- Non-Null Return:
TranslateExtension.ProvideValuealways returns a string; it never returns null. It guarantees a fallback string if the resource is missing. - Fallback Format: If a resource key is valid but not found, the return value follows the format
#stringnotfound# {key}. - Empty Key Handling: If the key passed to
TranslateExtensionis null or empty, the return value is exactly#stringnotfound#(without a trailing space or key name). - Visibility:
StringResourcesis markedinternal, restricting access to within the assembly. - Code Generation:
StringResourcesis auto-generated; manual edits to the file will be overwritten by the tooling (ResGen/Visual Studio).
4. Dependencies
- Internal Dependencies:
TranslateExtensiondepends onStringResourcesto perform the actual resource lookup viaStringResources.ResourceManager.
- External Framework Dependencies:
System.Windows.Markup: Required forMarkupExtensionandIServiceProvider(WPF specific).System.Resources: Required forResourceManager.System.Globalization: Required forCultureInfo.
- File Dependencies:
StringResources.Designer.csdepends on an underlying.resxfile (likelyStringResources.resx) which contains the actual key-value pairs for the localized strings.
5. Gotchas
- Culture Inconsistency:
TranslateExtensioncallsStringResources.ResourceManager.GetString(_key)without passing a culture argument. This relies onThread.CurrentUICulture. However,StringResourcesexposes a staticCultureproperty. If a developer setsStringResources.Cultureexplicitly, the strongly-typed properties (e.g.,CalibrationBehaviorText) will respect it, butTranslateExtensionwill ignore it and continue using the thread's current UI culture. - Silent Failures: The
TranslateExtensiondoes not throw exceptions for missing keys. Instead, it returns the error string#stringnotfound#. This is designed for debugging visibility but requires visual inspection of the UI to detect missing translations. - Designer File Edits: Because
StringResources.Designer.csis auto-generated, developers must not add custom logic or properties directly to this class. Changes must be made in the corresponding.resxfile.