jsonlocalizationregistry
title: “JsonLocalizationRegistry” sidebar: order: 99
Namespace: Bogoware.Localization
JSON-backed registry for managing localized message templates with culture fallback chain.
public class JsonLocalizationRegistry : ILocalizationRegistryInheritance Object → JsonLocalizationRegistry
Implements ILocalizationRegistry
Attributes NullableContextAttribute, NullableAttribute
Constructors
JsonLocalizationRegistry()
public JsonLocalizationRegistry()Methods
LoadFromJson(String, CultureInfo)
Loads message templates from a JSON or JSONC string (FQDN → template pairs) for the specified culture.
public void LoadFromJson(string json, CultureInfo culture)Parameters
json String
A JSON (or JSONC) object mapping fully qualified type names to format template strings
(e.g. { "MyApp.Errors.NotFound": "Resource '{Id}' was not found." }).
Both single-line (//) and block (/* */) comments are accepted, as well as trailing commas.
culture CultureInfo
The culture these templates belong to. Use CultureInfo.InvariantCulture for the default fallback.
Remarks:
When the same FQDN key already exists for the given culture, the new value silently overrides the previous one. This merge-on-conflict behavior lets downstream assemblies override templates defined by upstream assemblies.
TryGetTemplate(String, CultureInfo, String&)
Attempts to retrieve a template for the given FQDN and culture.
public bool TryGetTemplate(string fqdn, CultureInfo culture, String& template)Parameters
fqdn String
The fully qualified type name used as the template key.
culture CultureInfo
The desired culture for the lookup.
template String&
When this method returns , contains the resolved template.
When , set to .
Returns
Boolean
if a matching template was found; otherwise .
Remarks:
The lookup follows a 3-tier fallback: exact culture → parent culture → invariant culture (empty culture name). The first match wins.