Show / Hide Table of Contents

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.

Inheritance
object
LocalizedString
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Zaya.Primitives
Assembly: Zaya.Primitives.dll
Syntax
public sealed class LocalizedString

Constructors

| Edit this page View Source

LocalizedString(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 Source

Key

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 Source

GetValue(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.

| Edit this page View Source

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 text.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX