Interface IBobLocalizationProvider
- Namespace
- BlazOrbit.Localization
- Assembly
- BlazOrbit.Core.dll
Pluggable backend that resolves a translation for a precomputed key hash. Implementations hold their own per-culture cache; the framework never wraps them in an external cache layer.
public interface IBobLocalizationProvider
Remarks
The contract is intentionally minimal - one method, one lookup. The build-time source generator wires call sites to the provider chain declared on each BobLocalizationBundleAttribute; at runtime the chain is iterated in order and the first provider that returns true wins.
Cache key inside the provider is the hash only. Providers that need per-culture
sub-caches MUST select the sub-cache by culture before hashing - the framework
guarantees no two distinct call sites share a hash within a bundle.
Built-in implementations: BundleProvider (translations baked at
compile time from .tn files) and LiteralProvider (sentinel
that resolves to the source literal - terminal fallback, never fails).
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.
bool TryGet(BobLocalizationBundleSpec spec, ulong hash, CultureInfo culture, out string? value)
Parameters
specBobLocalizationBundleSpecCalling 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.
hashulongFNV-1a 64-bit hash of the source literal, precomputed at build time.
cultureCultureInfoCulture to resolve against; provider applies its own fallback rules within.
valuestringReceives the translation when this provider has a hit; null otherwise.