Table of Contents

Class LiteralProvider

Namespace
BlazOrbit.Localization.Providers
Assembly
BlazOrbit.Core.dll

Marker provider that declares the literal-fallback position in a bundle's chain. Always returns false - the source literal is carried by the caller (either the generator-emitted accessor method or BobLocalizer<T>) and surfaced as Microsoft.Extensions.Localization.LocalizedString.ResourceNotFound when no real provider matched.

public sealed class LiteralProvider : IBobLocalizationProvider
Inheritance
object
LiteralProvider
Implements

Remarks

Treating the literal as a "served" value inside this provider would erase the ResourceNotFound diagnostic that consumers rely on to detect untranslated keys. The type stays in the chain as a sentinel so Chain can declare it explicitly and the generator can reason about its presence at build time.

Constructors

LiteralProvider()

public LiteralProvider()

Methods

TryGet(BobLocalizationBundleSpec, ulong, CultureInfo, out string?)

Attempts to resolve a translation for the given hash in the requested culture, scoped to spec's bundle.

public bool TryGet(BobLocalizationBundleSpec spec, ulong hash, CultureInfo culture, out string? value)

Parameters

spec BobLocalizationBundleSpec

Calling bundle's spec. Providers MUST scope their lookup to this bundle - querying a global registry would allow another bundle that happens to share the same source literal (and therefore the same hash) to leak its translation back to the caller.

hash ulong

FNV-1a 64-bit hash of the source literal, precomputed at build time.

culture CultureInfo

Culture to resolve against; provider applies its own fallback rules within.

value string

Receives the translation when this provider has a hit; null otherwise.

Returns

bool

true when the provider served a value; false to defer to the next provider in the chain.