Skip to content

Commit

Permalink
Removes NameLocalizationKey, uses Name as the key.
Browse files Browse the repository at this point in the history
  • Loading branch information
tesar-tech committed Jan 23, 2025
1 parent ece265e commit ef5f29b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class RouterTabsOptions
{
/// <summary>
/// Func used for localizing router tabs names.
/// In: Name key, Out: Localized name
/// In: Name key, Out: Localized name.
/// Return null if localization isn't provided.
/// </summary>
public Func<string, string> NamesLocalizer { get; set; }
}
18 changes: 4 additions & 14 deletions Source/Extensions/Blazorise.Components/RouterTabsPageAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ namespace Blazorise.Components;
public class RouterTabsPageAttribute : Attribute
{
/// <summary>
/// Sets the name of the router tab.
/// Sets the name of the router tab.
/// The Name can be used as a key for the localization dictionary.
/// If left empty or null, <see href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.routedata.pagetype">RouteData.PageType</see>
/// will be used as the Name.
/// </summary>
public readonly string Name;

Expand All @@ -29,25 +32,12 @@ public class RouterTabsPageAttribute : Attribute
/// </summary>
public readonly bool Closeable;

/// <summary>
/// Localization key for retrieving name of the tab
/// </summary>
public readonly string NameLocalizationKey;

public RouterTabsPageAttribute( string Name, string TabClass = "", string TabPanelClass = "", bool Closeable = true )
{
this.Name = Name;
this.TabClass = TabClass;
this.TabPanelClass = TabPanelClass;
this.Closeable = Closeable;
}

public RouterTabsPageAttribute( string NameLocalizationKey, bool Closeable = true, string TabClass = "", string TabPanelClass = "" )
{
this.NameLocalizationKey = NameLocalizationKey;
this.TabClass = TabClass;
this.TabPanelClass = TabPanelClass;
this.Closeable = Closeable;
}

}
5 changes: 1 addition & 4 deletions Source/Extensions/Blazorise.Components/RouterTabsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ internal class RouterTabsItem
public string TabClass { get; set; }
public string TabPanelClass { get; set; }
public bool Closeable { get; set; } = true;
public string NameLocalizationKey { get; set; }
public string LocalizedName { get; set; }
public string LocalizedNameOrName => LocalizedName ?? Name;
}
Expand Down Expand Up @@ -104,8 +103,7 @@ internal void TrySetRouteData( RouteData routeData )
if ( routeData is not null )
{
SetRouterTabsItemFromPageAttribute( routerTabsItem, routeData.PageType );
if ( !string.IsNullOrWhiteSpace(routerTabsItem.NameLocalizationKey))
routerTabsItem.LocalizedName = options?.NamesLocalizer.Invoke( routerTabsItem.NameLocalizationKey );
routerTabsItem.LocalizedName ??= options?.NamesLocalizer.Invoke( routerTabsItem.Name ) ;
routerTabsItem.Body ??= CreateRouterTabsItemBody( routeData );
routerTabsItem.TypeName = routeData.PageType.FullName;
if ( string.IsNullOrWhiteSpace( routerTabsItem.Name ) )
Expand Down Expand Up @@ -137,7 +135,6 @@ private void SetRouterTabsItemFromPageAttribute( RouterTabsItem pageItem, Type p
if ( routerTabsPageAttr is not null )
{
pageItem.Name = routerTabsPageAttr.Name;
pageItem.NameLocalizationKey = routerTabsPageAttr.NameLocalizationKey;
pageItem.TabClass = routerTabsPageAttr.TabClass;
pageItem.TabPanelClass = routerTabsPageAttr.TabPanelClass;
pageItem.Closeable = routerTabsPageAttr.Closeable;
Expand Down

0 comments on commit ef5f29b

Please sign in to comment.