-
Notifications
You must be signed in to change notification settings - Fork 65
IViewLocalizer not working when used from a external assembly with a resource file #328
Comments
@chanaka1 we feel this is a problem of abstraction that's not really solvable in general. Your ViewLocalizer will look for resx files, but maybe that library has po files instead. In your specific case you can make that assumption because you're the author of both, but in general it's making assumptions about implementations outside the current project. We think the correct way to go about this would be to get a IStringLocalizer from some method internal to the library hosting the views, so: |
I went trough the current implementation of ViewLocalizer The problem is that, to generate the path it is using the hostingEnvironment.ApplicationName. where if the view is loaded from a different assembly the generated path is wrong for the _localizerFactory
I have my own IViewLocalizer implementation getting the current assembly name from ControllerActionDescriptor
Is there a better way that this can be implemented ? |
If you mean is there a better way to get the AssemblyName off the ControllerType you could do something like |
@chanaka1 Can you share working sample, please? I've tried download your sample repo, but IViewLocalizer still not working. I think that will be very useful. |
Functional impact
There is no way to load localization culture for views with a resource file in a external assembly or part mvc application (MVC Module)
Minimal repro steps
Use a MVC part application and try to localize the view in the part application to load from a resource file
Sample Demo Git Repo
Expected result
The view should load with the en-US culture values from the Resource folder
Actual result
View loads with default values
Further technical details
FYI : not sure if im doing something wrong i think it must be a bug. Thanks in advance
The text was updated successfully, but these errors were encountered: