6.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T11:23:12.329617+00:00 | zai-org/GLM-5-FP8 | 1 | dbbc3094853fd65f |
Documentation: DTS.Viewer.Resources Localization Module
1. Purpose
This module provides localization/internationalization support for the DTS Viewer WPF application. It enables XAML-based string lookup through a markup extension pattern, allowing UI elements to bind to localized resources declaratively. The TranslateExtension class serves as a bridge between XAML markup and the underlying StringResources resource manager, while StringResources provides strongly-typed, auto-generated access to localized strings stored in compiled resource files (.resx).
2. Public Interface
TranslateExtension (Class)
Namespace: DTS.Viewer
Attributes: [MarkupExtensionReturnType(typeof(string))]
A WPF markup extension that resolves localization keys to their corresponding string values at runtime.
| Member | Signature | Description |
|---|---|---|
| Constructor | TranslateExtension(string key) |
Initializes the extension with the resource key to look up. Stores the key in a readonly field _key. |
ProvideValue |
public override object ProvideValue(IServiceProvider serviceProvider) |
Returns the localized string for the provided key. Returns NotFound constant if key is null/empty, or NotFound + " " + _key if the key is not found in resources. |
NotFound |
private const string NotFound = "#stringnotfound#" |
Fallback string returned when a key is invalid or missing. |
StringResources (Class)
Namespace: DTS.Viewer.Resources
Accessibility: internal
Attributes: [GeneratedCode], [DebuggerNonUserCode], [CompilerGenerated]
An auto-generated strongly-typed resource class providing access to localized strings.
| Member | Signature | Description |
|---|---|---|
ResourceManager |
internal static global::System.Resources.ResourceManager ResourceManager { get; } |
Lazily-initialized, cached ResourceManager instance for the DTS.Viewer.Resources.StringResources resource bundle. |
Culture |
internal static global::System.Globalization.CultureInfo Culture { get; set; } |
Gets or sets the current UI culture for resource lookups. Overrides Thread.CurrentUICulture for this resource class. |
Localized String Properties (all internal static string):
| Property | Default Value (from comments) |
|---|---|
ChartOptionsHeader |
"Chart Options" |
GraphsDefaultTitle |
"Graphs " |
ModificationsHeader |
"Modify" |
SavePDFError |
"Error occurred saving chart to PDF" |
SavePDFSuccess |
"Chart saved succesfully as {0}{1} and {2}{3}" |
SettingsTitle |
"Settings" |
TestIDsDefaultTitle |
"Test IDs" |
TestsDefaultTitle |
"Tests " |
3. Invariants
-
Key immutability: The
_keyfield inTranslateExtensionisreadonlyand set only at construction time. -
Null safety:
ProvideValuewill never return null. It returns either the localized string,NotFound(for null/empty keys), orNotFound + " " + _key(for missing keys). -
ResourceManager singleton: The
ResourceManagerproperty uses a check-then-create pattern with a temporary variable to ensure thread-safe lazy initialization. -
Resource name mapping: The
ResourceManageris initialized with the base name"DTS.Viewer.Resources.StringResources", which must match the embedded resource path. -
Culture fallback: If
Cultureproperty is not explicitly set (resourceCultureis null),ResourceManager.GetStringuses the current thread'sCurrentUICulture.
4. Dependencies
This module depends on:
System(core .NET types)System.Windows.Markup- forMarkupExtensionbase class andMarkupExtensionReturnTypeAttributeSystem.Resources- forResourceManagerclassSystem.Globalization- forCultureInfoclassSystem.CodeDom.Compiler,System.Diagnostics,System.Runtime.CompilerServices- for auto-generated attributes- Resource files (.resx) - The actual localized string data backing
StringResources(not included in source, but implied by the designer file)
What depends on this module:
- XAML files in DTS.Viewer - Use
{x:Static res:StringResources.PropertyName}or{local:Translate KeyName}syntax for localized strings - PDF export functionality - Uses
SavePDFSuccessandSavePDFErrorstrings - Chart/Graph UI components - Use
ChartOptionsHeader,GraphsDefaultTitle,ModificationsHeader - Settings UI - Uses
SettingsTitle - Test-related UI - Uses
TestIDsDefaultTitle,TestsDefaultTitle
5. Gotchas
-
StringResourcesisinternal: The class cannot be accessed from outside theDTS.Viewerassembly. External libraries cannot directly use these resources. -
Missing key behavior: Missing localization keys do not throw exceptions. Instead, they return
"#stringnotfound# {key}", which may appear in production UI if resources are misconfigured. This is intentional fallback behavior but could mask configuration errors. -
Typo in resource string: The
SavePDFSuccessresource contains "succesfully" (missing one 'l') per the source comments. This typo originates from the .resx file, not the generated code. -
Trailing spaces:
GraphsDefaultTitleandTestsDefaultTitlehave trailing spaces in their default values ("Graphs " and "Tests "). This may be intentional for UI layout but could cause issues if trimmed unexpectedly. -
Format string dependency:
SavePDFSuccessexpects 4 format arguments ({0}{1} and {2}{3}). Callers must provide exactly 4 arguments or aFormatExceptionwill occur at runtime. -
Auto-generated file warning:
StringResources.Designer.csis regenerated by tooling. Manual edits will be lost. The underlying.resxfile is the source of truth.