Page view counter
How to have localization follow browser language Subscribe to this thread
Last post 07-13-2008 10:01 AM by slyi. 4 replies.
Sort Posts:
07-10-2008 6:44 PM
How to have localization follow browser language

I am developing a Silverlight 2 application.

I have been able to embed multiple string resources into my .xap file.  I have found how I can select which language to display by adding:

<param name="culture" value="de" />
<param name="uiculture" value="de" />

To my <object> section in html.

What I would like to do is have the culture and uiculture follow the language(s) configured in my browser (auto detect).

Does anyone know how I can do that with javascript?  Or straight html?

Thanks for the help,

Matt

Matt Brooks

Loading...
Joined on 05-05-2008
Posts 6
07-11-2008 4:07 AM
Re: How to have localization follow browser language

Please see http://silverlight.net/forums/p/14007/50506.aspx#50506

<param name="culture" value="auto" />
<param name="uiculture" value="auto" />

slyi

Loading...
Joined on 09-16-2005
Ireland
Posts 186
07-11-2008 11:12 AM
Re: How to have localization follow browser language

 I am using Silverlight 2 Beta 2.

<param name="culture" value="auto" />
<param name="uiculture" value="auto" /> 

This does not work for me.  I am using Firefox and set one and only one language, de.  My app still showed en-US as my culture and UICulture.

Any other ideas?

Thanks,

Matt

Matt Brooks

Loading...
Joined on 05-05-2008
Posts 6
07-12-2008 2:38 PM
Re: How to have localization follow browser language

That is strange i just tried it now as well and it doesnt seem to work either, maybe a bug in beta 2. It was meant to be working in beta2.

As a workaround you could add it dynamiclly on the server side eg:

<%@ Page Language="C#" AutoEventWireup="true" UICulture="auto" Culture="auto" %><%@ import namespace="System.Threading" %>

<param name="Culture" value="<%=Thread.CurrentThread.CurrentCulture.Name %> />
<param name="UICulture" value="<%=Thread.CurrentThread.CurrentCulture.Name %>" />

 

 

 

 

 

slyi

Loading...
Joined on 09-16-2005
Ireland
Posts 186
07-13-2008 10:01 AM
Marked as Answer
Re: How to have localization follow browser language

Actually it is working eg: http://cid-2b248d261d0e0035.skydrive.live.com/self.aspx/Public/culture-equals-auto.zip

But it is not based on user accept language host header list, from you user browser language, as this is not available on the client side, only server side. What is available on the client side is OS language which you change in control panel.  http://www.microsoft.com/library/media/1033/windowsxp/images/using/setup/winxp/regional-options-click-ok.jpg

Please note the server side method is much more targeted, and i recommend this more than the client side polling.

 

slyi

Loading...
Joined on 09-16-2005
Ireland
Posts 186
Microsoft Communities