zHaytam / SmartBreadcrumbs

A utility library for ASP.NET Core (both MVC and Razor Pages) websites to easily add and customize breadcrumbs.
https://blog.zhaytam.com/2018/06/24/asp-net-core-using-smartbreadcrumbs/
MIT License
161 stars 77 forks source link

Localized title #94

Closed sylvaincaillot closed 3 years ago

sylvaincaillot commented 3 years ago

Hi,

I have a multilingual site and I tried the following for having localized breadcrumbs: [DefaultBreadcrumb(Resources.Generic.ResourceManager.GetString("Node.News"))]

However, I keep getting the following error: Error CS0182 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

I remember there was PR on this matter but I don't see how to easily implement localized bredcrumbs.

Thank you

zHaytam commented 3 years ago

Hello, You can take a look at the example project. You need to specify the resource type that contains your localizations:

services.AddBreadcrumbs(GetType().Assembly, options =>
{
    // Testing
    options.DontLookForDefaultNode = true;
    options.ResourceType = typeof(Resx.BreadcrumbResources);
});

And the library should use it for your titles.