Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

CultureInfo.CurrentUICulture is always default language - how to detect browser language

$
0
0

There are a lot of guys and most have things that make my code not work so i guess i'm missing something.I have a server side blazor app and i want the default language of the ui, or computer, to be the language selected

var supportedCultures = new[] { "fr-CA", "en-CA" };var localizationOptions = new RequestLocalizationOptions()    .SetDefaultCulture(supportedCultures[0])    .AddSupportedCultures(supportedCultures)    .AddSupportedUICultures(supportedCultures);
@inject IStringLocalizerFactory Loc@using System.Globalization<PageTitle>Produits</PageTitle><div class="row"><h1>Produits</h1>    @if (ProductCategories != null && ProductCategories.Count() > 0 && SelectedProductCategory == null)    {        foreach (ProductCategory productCategory in ProductCategories)        {<button class="square-button" @onclick="(() => OnSelectCategory(productCategory.ID))"><img class="small-img" src="@productCategory.Image" /><br /><span class="button-text">@(CultureInfo.CurrentUICulture.Name.Contains("fr") ? productCategory.NameFR : productCategory.NameEN)</span></button>        }    }

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>