0
votes

I am working on multi Lingual application in c# asp.net MVC, in which server, client or both may have different languages other than English. My development machine has English as default language, and using language bar in windows, I have set my current language to French (belgium), my client end browser language is Dutch(belgium). For every request I used to change Thread Current Culture to Dutch(client end browser language) using globalization techniques as follows.

protected void Application_BeginRequest(object sender, EventArgs e)
{
    HttpCookie userCookie = Request.Cookies["Culture"];
    string cultureCode = "en-US";
    if (userCookie != null)
    {
        cultureCode = userCookie.Value;
    }
    CultureInfo culture = new CultureInfo(cultureCode);
    Thread.CurrentThread.CurrentCulture = culture;
    Thread.CurrentThread.CurrentUICulture = culture;
}

I wanted to find OS current culture, therefore, I used

CultureInfo.InstalledUICulture

to find OS current culture, which should be French(Belgium) FR-BE, but every time it is returning me en-US English(united states). I already know that problem is with windows, it always returns default windows culture instead of current Culture as explained in this question. I wanted to know, is there any way to find current OS culture which is French(Belgium) FR-BE on my server.

1
I don't see much value in figuring "default server's culture"... Consider specifying one explicitly in Web.config <globalization uiculture... instead (msdn.microsoft.com/en-us/library/vstudio/…)Alexei Levenkov
Side note: Unless you means something different than "using language bar in windows" have zero impact on current culture, it only impact what language will be used in input fields..Alexei Levenkov

1 Answers

0
votes

I believe you might want to check:

public static CultureInfo CurrentCulture { get; set; }
public static CultureInfo CurrentUICulture { get; set; }

This should contain the default OS culture when your application starts.