Recommendation on the usage of language and/or locale in Sitefinity
I am looking for a recommendation on the usage of language and/or locale in Sitefinity.
In Sitefinity you can translate content into separate languages and basically ignore the locale, or you can pair language and locale. The problem is that the locale is specific to a country/language pair. Instead of being country specific it would be nice to be regional specific.
For example, if a customer comes to our web site and they are from somewhere in France I want them to be transferred to the European section of our web site. If the user comes from the United States I want them to be transferred to our North American section of our web site.
Does anyone have a recommendation on this type of setup or do you have a better idea???
Thanks,
Craig
Hello Craig,
We don't have this out-of-the-box, but you can check the browser language of the user and depending on that to redirect him to the correct location of the site. Here's an example (this is one possible approach)
Code in the global.asax file:
protected void Session_Start(object sender, EventArgs e) System.Web.HttpContext context = System.Web.HttpContext.Current; string curUrl = context.Request.Url.ToString(); string browserLanguage = ""; try browserLanguage = HttpContext.Current.Request.UserLanguages[0]; catch browserLanguage = "en"; if (browserLanguage == "de-DE") if ((curUrl == "http://www.alurehab.com") || (curUrl == "http://www.alurehab.de")) context.Response.Redirect("http://www.alurehab.de"); else if (browserLanguage == "da-DK") if ((curUrl == "http://www.alurehab.de") || (curUrl == "http://www.alurehab.com")) context.Response.Redirect("http://www.alurehab.dk"); else context.Response.Redirect("http://www.alurehab.com"); <script language="C#" runat="server"> protected void Page_Load(object sender, EventArgs e) if(Request.UserLanguages != null && Request.ServerVariables["script_name"] == "/") string language = Request.UserLanguages[0]; if(!string.IsNullOrEmpty(language)) //Get the culture name - and make sure it's in the RFC 1766 standard <languagecode2>-<country/regioncode2> //i.e. en-GB, so it's easier to check for if (language.Length < 3) language += "-" + language.ToUpper(); //Redirect to the correct page based on language, default to english switch(language) case "en-US": Response.Redirect("/home.aspx"); break; case "nl-BE": Response.Redirect("/startpagina.aspx"); break; case "fr-BE": Response.Redirect("/acceuil.aspx"); break; default: Response.Redirect("/home.aspx"); break; </script>Thanks for the information.