Closed ConnerOrth closed 3 years ago
How about something like:
[Breadcrumb("Key Lang", Localized = true, LocalizerType = typeof(SharedResource)]
// Or by default, use the controller type
[Breadcrumb("Key Lang", Localized = true)]
I can then use the IStringLocalizerFactory
to create a IStringLocalizer
and use it.
Although for Razor Pages I'm not sure how localization works.
I would suggest to always run the title through localization, if a IStringLocalizerFactory has been added to the DI container. (You could create a property on the BreadcrumbOptions to hold a reference to the stringlocalizerfactory or the localizer resource?) And otherwise just return whatever title is passed.
That way you are not responsible for handling and/or maintaining the localization resource. You could potentially add a bool to prevent localizing a breadcrumb so like your suggestion but only use it to stop localizing.
Just thinking out loud here.
But in order to localize something, you need IStringLocaliser<>
which needs to be injected and is generic.
The only way you can create one is using the Factory and a Type.
How would the localization always be ran without these?
Check for existence of the factory, and if factory is not registered then do not run through translation, else use localizer.
So basically run localization whenever possible?
Yes this way it's up to the consumer of the breadcrumb package to provide the translation, if any.
Hi, I use this Breadcrumbs, there are nice, but i need this translations :) . Will you make that change in the future? It would be nice. :)
what happened with this request?
Are there any updates on this issue?
Unfortunately, no. It's very hard to find the time for features like these 😞
Hi, I also needed this functionality so I have implemented it. I'm going to do a pull request so we can see the code and see if the implementation can be improved.
Fixed in 3.6.0 thanks #78 (@julianyus).
excellent, I will use
Let me know if you have any problem or you need help with configuration.
@julianyus and @zHaytam my English is not that good, make a change to your code, so that different namespaces can be used in language resources and no additional class needs to be created in the project.
if you allow me to submit my pull request for review
I am not sure I get what you kean, but a PR is welcome as always
@zHaytam you add me as contributors, please
You need to Fork the project, do the modification in your repo then create a pull request
sorry, you are right
@zHaytam I send the PR for you review
Make it possible for breadcrumbs to be localized.