Class LocalizedString
Represents a string that can be localized. Supports two modes:
- Localized via a resolver function (typically a .resx
ResourceManager). - Invariant — created via Invariant(string) and never translated.
All source strings live in resource files; no English defaults are embedded in code.
Inherited Members
Namespace: Zaya.Primitives
Assembly: Zaya.Primitives.dll
Syntax
public sealed class LocalizedString
Constructors
| Edit this page View SourceLocalizedString(string, Func<CultureInfo, string>)
Initializes a new instance of the LocalizedString class with a resolver.
Declaration
public LocalizedString(string key, Func<CultureInfo, string> resolver)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Resource key for lookup (e.g. "Ocr_EngineName"). Used as fallback when the resolver returns null or empty. |
| Func<CultureInfo, string> | resolver | Function that resolves the key to a localized string for a given culture. |
Properties
| Edit this page View SourceKey
Gets the resource key used for localization. For invariant strings this equals the invariant text itself.
Declaration
public string Key { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceGetValue(CultureInfo)
Returns the localized value for the specified culture. Falls back to Key when the resolver returns null or empty.
Declaration
public string GetValue(CultureInfo culture)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | The target culture. |
Returns
| Type | Description |
|---|---|
| string | The localized or invariant string. |
Invariant(string)
Creates an invariant string that is never localized (e.g. log messages, internal IDs).
Declaration
public static LocalizedString Invariant(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The invariant text. |
Returns
| Type | Description |
|---|---|
| LocalizedString | A LocalizedString that always returns |