-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Localization]: Fix ViewLocalizer so it works for layouts too #2767
Comments
@DamianEdwards do we want this for beta8? If so, we need to discuss a design. |
Hit this issue while experimenting. For the same reason, localization does not work as expected in Suggest |
Can you clarify? Do you mean that _ViewStart is picking up resources from the real view that's running? If so, I agree that's wrong. |
Yes, that's what I and @kirthik meant. Fortunately one design (thinking of the Needs Design label) is a one-line fix. |
ViewLocalizer should use ViewContext.ExecutingFilePath when constructing the resource base name |
- Always prepend with application name and let underlying `IStringLocalizerFactory` do the name gymnastics - Use ExecutingFilePath instead of view name - Trim off the file extension (so your resource doesn't have to have ".cshtml" in its name) - Improved doc comments - Added tests to cover ViewLocalizer behavior - #3718 - #2767
- Always prepend with application name and let underlying `IStringLocalizerFactory` do the name gymnastics - Use ExecutingFilePath instead of view name - Trim off the file extension (so your resource doesn't have to have ".cshtml" in its name) - Improved doc comments - Added tests to cover ViewLocalizer behavior - #3718 - #2767
…se name - follow-up to #2767 - resources are now associated with specific page, not the `IView` when the `ViewContext` was created nit: remove unused `Resources` class
ViewLocalizer
cannot be used on layout pages since the logic inContextualize
method reads current view to get the resources file. SinceViewContext.View
property does not point to layout, layout specific resources are not localized. Today we have to useIStringLocalizer
for this scenario.We should come up with a solution where
ViewLocalizer
works for layouts too.The text was updated successfully, but these errors were encountered: