Class BobLocalizationBundleAttribute
- Namespace
- BlazOrbit.Localization
- Assembly
- BlazOrbit.Core.dll
Declares a localization bundle anchored to a marker TResource type. Applied at the
assembly level (typically on the AssemblyInfo of a package that ships translations)
so the source generator and runtime registry both discover the bundle without reflection
in consumer code.
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
public sealed class BobLocalizationBundleAttribute : Attribute
- Inheritance
-
objectAttributeBobLocalizationBundleAttribute
Remarks
The marker type itself has no members - it acts as a strongly-typed key for
IStringLocalizer<TResource> injection. Each marker type can have at most one
bundle attribute; a single assembly may declare multiple bundles by repeating the attribute
with different marker types.
DefaultCulture declares the culture in which the source literals are written - the source generator hashes those literals, and the runtime fallback chain terminates at that culture (returning the literal itself when nothing else matches).
Chain is an ordered list of provider System.Types implementing
IBobLocalizationProvider. The runtime iterates the chain in declaration order;
the first provider that returns true wins. Include
typeof(LiteralProvider) as the last entry to guarantee the source literal as the
terminal fallback.
Constructors
BobLocalizationBundleAttribute(Type)
Initialises the attribute for the supplied marker type.
public BobLocalizationBundleAttribute(Type resourceType)
Parameters
resourceTypeType
Properties
Chain
Ordered provider types. The runtime resolves each via System.IServiceProvider at
first use, then caches the resolved instance. Leave empty to use the default chain of
[BundleProvider, LiteralProvider].
public Type[] Chain { get; init; }
Property Value
- Type[]
DefaultCulture
Culture of the source literals in code. Defaults to en-US.
public string DefaultCulture { get; init; }
Property Value
- string
ResourceType
Marker type used as TResource for IStringLocalizer<TResource> injections.
public Type ResourceType { get; }
Property Value
- Type
TranslationsFolder
Folder (relative to the project root) where the source generator looks for .tn
translation files. Defaults to Translations.
public string TranslationsFolder { get; init; }
Property Value
- string