Class BOBCultureSelector
- Namespace
- BlazOrbit.Localization.Shared
- Assembly
- BlazOrbit.Localization.Shared.dll
public class BOBCultureSelector : BOBVariantComponentBase<BOBCultureSelector, BOBCultureSelectorVariant>, IVariantComponent<BOBCultureSelectorVariant>, IVariantComponent, IHasSize
- Inheritance
-
objectComponentBaseBOBCultureSelector
- Implements
- Derived
- Inherited Members
Constructors
BOBCultureSelector()
public BOBCultureSelector()
Fields
_currentCulture
protected CultureInfo _currentCulture
Field Value
- CultureInfo
Properties
BuiltInTemplates
protected override IReadOnlyDictionary<BOBCultureSelectorVariant, Func<BOBCultureSelector, RenderFragment>> BuiltInTemplates { get; }
Property Value
- IReadOnlyDictionary<BOBCultureSelectorVariant, Func<BOBCultureSelector, RenderFragment>>
DefaultVariant
Default variant used when no explicit variant is specified.
public override BOBCultureSelectorVariant DefaultVariant { get; }
Property Value
FlagResolver
Optional override for the flag emoji/glyph shown next to each culture. Receives the System.Globalization.CultureInfo and returns the rendered string; when null, falls back to GetFlag(CultureInfo).
[Parameter]
public Func<CultureInfo, string>? FlagResolver { get; set; }
Property Value
- Func<CultureInfo, string>
ForceReload
When true, switching culture triggers a full-page reload
(Navigation.NavigateTo(forceLoad: true)). When false
(default), the current thread's System.Globalization.CultureInfo is updated in-place
and the consumer receives the OnCultureChanged event without
losing form state, modals, or scroll position.
[Parameter]
public virtual bool ForceReload { get; set; }
Property Value
- bool
Remarks
In-place switching only re-renders components that read CultureInfo.CurrentUICulture
during their next render — it does not retroactively re-format already-rendered DOM.
Set this to true if your app caches culture-dependent values eagerly.
Localizer
[Inject]
protected IStringLocalizer<BOBCultureSelectorResources> Localizer { get; set; }
Property Value
- IStringLocalizer<BOBCultureSelectorResources>
OnCultureChanged
Raised after the active culture has changed.
[Parameter]
public EventCallback<CultureInfo> OnCultureChanged { get; set; }
Property Value
- EventCallback<CultureInfo>
Settings
[Inject]
protected LocalizationSettings Settings { get; set; }
Property Value
ShowFlag
When true, the flag glyph is rendered next to each culture entry.
[Parameter]
public bool ShowFlag { get; set; }
Property Value
- bool
ShowName
When true, the human-readable culture name is rendered next to each entry.
[Parameter]
public bool ShowName { get; set; }
Property Value
- bool
Size
Visual size of the culture selector.
[Parameter]
public BOBSize Size { get; set; }
Property Value
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
GetFlag(CultureInfo)
protected string GetFlag(CultureInfo culture)
Parameters
cultureCultureInfo
Returns
- string
OnDropdownCultureChanged(string?)
protected virtual Task OnDropdownCultureChanged(string? cultureName)
Parameters
cultureNamestring
Returns
- Task
OnInitializedAsync()
Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.
Override this method if you will perform an asynchronous operation and want the component to refresh when that operation is completed.
protected override Task OnInitializedAsync()
Returns
- Task
A System.Threading.Tasks.Task representing any asynchronous operation.
RenderDropdown()
protected virtual RenderFragment RenderDropdown()
Returns
- RenderFragment
RenderFlags()
protected virtual RenderFragment RenderFlags()
Returns
- RenderFragment
SetCultureAsync(string)
protected virtual Task SetCultureAsync(string cultureName)
Parameters
cultureNamestring
Returns
- Task