--- source_files: - DataPRO/Modules/TestSetups/Imports/TTS/Resources/StringResources.ja.Designer.cs - DataPRO/Modules/TestSetups/Imports/TTS/Resources/TranslateExtension.cs - DataPRO/Modules/TestSetups/Imports/TTS/Resources/StringResources.Designer.cs generated_at: "2026-04-16T04:49:54.783331+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "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**: ```csharp public TranslateExtension(string key) ``` Initializes the extension with a resource key. - **Fields**: ```csharp public const string NotFound = "#stringnotfound#"; ``` Fallback value returned when a resource lookup fails. - **Method**: ```csharp public override object ProvideValue(IServiceProvider serviceProvider) ``` Returns the localized string corresponding to `_key`, or `NotFound` if `_key` is null/empty, or `NotFound + " " + _key` if 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 string` properties with `get` accessors that call `ResourceManager.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; see `StringResources.Designer.cs` for all ~150 entries.)* - **Static Properties**: ```csharp internal static ResourceManager ResourceManager { get; } internal static CultureInfo Culture { get; set; } ``` Provide access to the underlying resource manager and override culture for lookups. ### 3. Invariants - **Resource key must be non-null/non-empty** for successful lookup; otherwise, `TranslateExtension.ProvideValue` returns `NotFound`. - **Missing resource values** result in `NotFound + " " + _key` (e.g., `"#stringnotfound# MyKey"`), not `null`. - **`StringResources` is auto-generated**; manual edits are overwritten. Changes must be made via `.resx` files. - **Thread-safety**: `ResourceManager` and `Culture` are 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 `NotFound` or the fallback string. ### 4. Dependencies - **Depends on**: - `System.Resources.ResourceManager` (for resource lookup) - `System.Globalization.CultureInfo` (for culture-specific lookups) - `System.Windows.Markup.MarkupExtension` (for `TranslateExtension`) - `System` and `System.ComponentModel` (via attributes) - **Used by**: - WPF XAML UI elements via `{tts:Translate KeyName}` bindings (inferred from `MarkupExtension` usage). - Other modules in `TTSImport` namespace (e.g., import logic, error handlers) via `StringResources.PropertyName` access. - **No external dependencies beyond .NET Framework 4.0+** (based on runtime version in header comment). ### 5. Gotchas - **Hardcoded fallback format**: `NotFound + " " + _key` is 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`**: While `StringResources` properties like `SensorNotFound` contain format placeholders (e.g., `{0}`), `TranslateExtension` does not support passing arguments—consumers must manually format strings (e.g., `string.Format(StringResources.SensorNotFound, sensorName)`). - **Culture override via `StringResources.Culture`** affects *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.cs` is empty** in the provided source—this may indicate incomplete localization or a build artifact issue. The Japanese resource strings are actually in `StringResources.Designer.cs` (which lacks language-specific suffix), suggesting the `.ja.` file may be a placeholder or legacy artifact. - **No null-safety for `ResourceManager.GetString`**: Returns `null` if key is missing, which `TranslateExtension` converts to the fallback string. However, if `ResourceManager` itself 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#`.