BlazorStatic icon indicating copy to clipboard operation
BlazorStatic copied to clipboard

Add localization to the BlazorStatic website

Open junovell opened this issue 8 months ago • 2 comments

Feature Request: Route-Based Localization for the Documentation Site

Add route-based localization support to the BlazorStatic documentation website — something like /en, /fr, etc., to showcase the capabilities of the library.

This would be implemented following the official Microsoft approach:
🔗 Localization in ASP.NET Core

To handle culture detection from the URL, the BlazorServerUrlRequestCultureProvider NuGet package would be used. It extracts the culture from the route and sets it for the current request, allowing us to ditch the cookie based approach Microsoft uses.

junovell avatar Apr 18 '25 17:04 junovell

I wonder how these will be solve:

  • page /en/somepage and its french equivalent /fr/somepage
    • or /en/somepage and /en/unepage ?
  • blog/en/post1 and its french equivalent which source is in different md.
  • can we do @page "/{lang}/{post}" or this is not how it's done?
  • I guess we need some localization nav menu and similar - this should probably go with .resx files, right?
  • we need to cleverly iterate over all the pages, but on the other hand we don't wanna complicate things much. Maybe BlazorStatic should provide some simplification to that (list of languages and some convention where the language is put).

tesar-tech avatar Apr 18 '25 20:04 tesar-tech

  1. we can either do /en/home, /fr/accueil or /en/home, /fr/home.

  2. we can have translated copies of each post with the name post.lang.md, when a page is loaded we check if the requested language is available in the post else we use the default one.

  3. maybe? but then it will be possible for the user to type any random text in the first parameter, the approach i use is multiple @page directives (that's why i did the previous PR)

  4. yeah we'll use .resx files so we can make use of the Microsoft Localization extension.

  5. this feature will not be included in BlazorStatic the library (sorry if i made it sound like that), just the documentation website, adding it to the library doesn't make sense when it's super easy to implement.

junovell avatar Apr 18 '25 21:04 junovell