dotnet / dotnet/aspnetcore

Localized views with Razor Pages

Open
#40,186 15 comments 5 reactions 0 assignees View on GitHub
area-mvc feature-localization feature-razor-pages
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

Bringing #4873 `Localized views with Razor Pages` back to discussion for .net 7.0

> In Razor Pages, we can inject IViewLocalizer to work with localized resources - good. But sometimes, especially on content-heavy, rather static pages, it would be nice to have location specific views, i.e. MyPage.en.cshtml and MyPage.de.cshtml etc.
>
>My expection was that once I configure AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, ...) Razor Pages also would be resolved by their base name, but I quickly realized there might be a problem with how the corresponding PageModel should be used/resolved. I couldn't get this to work at all - is this scenario even supported with Razor Pages?
>
>In any case, I think the corresponding [docs](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization) should be more explicit about what's possible with Razor Pages and potential limitations.

### Describe the solution you'd like

View location expanders should apply to Razor pages too.

### Additional context

@DamianEdwards @rynowak @pranavkm

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.