5.4 KiB
5.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T04:49:54.783331+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 977bda595f1f1bda |
Resources
Documentation: TTS Import Localization Resources
1. Purpose
This module provides localized string resources and a WPF MarkupExtension for internationalization within the TTS (Test Setup) import functionality. It enables UI elements and messages to be displayed in the user’s preferred language (currently Japanese, based on the StringResources.ja.Designer.cs file name) by retrieving localized strings from embedded .resx-generated resources. The TranslateExtension allows declarative binding of localized text in XAML, while StringResources provides strongly-typed access to all localized strings used in the import pipeline.
2. Public Interface
TranslateExtension class
- Namespace:
TTSImport - Inherits:
MarkupExtension - Constructor:
Initializes the extension with a resource key.
public TranslateExtension(string key) - Fields:
Fallback value returned when a resource lookup fails.
public const string NotFound = "#stringnotfound#"; - Method:
Returns the localized string corresponding to
public override object ProvideValue(IServiceProvider serviceProvider)_key, orNotFoundif_keyis null/empty, orNotFound + " " + _keyif the key exists but has no value in the resource manager.
StringResources class
- Namespace:
TTSImport.Resources - Type: Internal, auto-generated strongly-typed resource class
- Properties: All are
internal static stringproperties withgetaccessors that callResourceManager.GetString(key, resourceCulture). Examples include:string AAF_SLICE { get; }string Added { get; }string ImportTestSetup_DuplicateChannelCode { get; }string SensorNotFound { get; }
(Full list of keys is extensive; seeStringResources.Designer.csfor all ~150 entries.)
- Static Properties:
Provide access to the underlying resource manager and override culture for lookups.
internal static ResourceManager ResourceManager { get; } internal static CultureInfo Culture { get; set; }
3. Invariants
- Resource key must be non-null/non-empty for successful lookup; otherwise,
TranslateExtension.ProvideValuereturnsNotFound. - Missing resource values result in
NotFound + " " + _key(e.g.,"#stringnotfound# MyKey"), notnull. StringResourcesis auto-generated; manual edits are overwritten. Changes must be made via.resxfiles.- Thread-safety:
ResourceManagerandCultureare managed with static fields and lazy initialization; no explicit synchronization is present in the generated code. - No validation is performed on resource keys; invalid keys silently return
NotFoundor the fallback string.
4. Dependencies
- Depends on:
System.Resources.ResourceManager(for resource lookup)System.Globalization.CultureInfo(for culture-specific lookups)System.Windows.Markup.MarkupExtension(forTranslateExtension)SystemandSystem.ComponentModel(via attributes)
- Used by:
- WPF XAML UI elements via
{tts:Translate KeyName}bindings (inferred fromMarkupExtensionusage). - Other modules in
TTSImportnamespace (e.g., import logic, error handlers) viaStringResources.PropertyNameaccess.
- WPF XAML UI elements via
- No external dependencies beyond .NET Framework 4.0+ (based on runtime version in header comment).
5. Gotchas
- Hardcoded fallback format:
NotFound + " " + _keyis used for missing values, which may produce confusing output (e.g.,"#stringnotfound# MyKey"). No logging or telemetry is included. - No support for parameterized strings in
TranslateExtension: WhileStringResourcesproperties likeSensorNotFoundcontain format placeholders (e.g.,{0}),TranslateExtensiondoes not support passing arguments—consumers must manually format strings (e.g.,string.Format(StringResources.SensorNotFound, sensorName)). - Culture override via
StringResources.Cultureaffects all subsequent lookups globally; misuse may cause inconsistent localization. - Japanese-only resource file is present (
StringResources.ja.Designer.cs), but no other language variants are visible in the provided files. Localization for other languages may be missing or managed elsewhere. StringResources.ja.Designer.csis empty in the provided source—this may indicate incomplete localization or a build artifact issue. The Japanese resource strings are actually inStringResources.Designer.cs(which lacks language-specific suffix), suggesting the.ja.file may be a placeholder or legacy artifact.- No null-safety for
ResourceManager.GetString: Returnsnullif key is missing, whichTranslateExtensionconverts to the fallback string. However, ifResourceManageritself is misconfigured, lookups may fail silently. - No compile-time validation of resource keys: Typos in XAML (e.g.,
{tts:Translate MyKye}) will only surface at runtime as#stringnotfound#.