PDA

View Full Version : UserLocale and Mozilla


sebastijanp
10-23-2005, 11:56 PM
Hi!

I use in aspx which extends Spring.Web.UI.UserControl

string userLocaleTwoLetterISOLanguageName = UserLocale.TwoLetterISOLanguageName;
if ("en".Equals(userLocaleTwoLetterISOLanguageName))
{...

In Mozilla browser this does not work correctly! UserLocale.TwoLetterISOLanguageName is wrong!
So I tried with:
string userLocaleTwoLetterISOLanguageName = System.Threading.Thread.CurrentThread.CurrentCultu re.TwoLetterISOLanguageName;

And it somehow worked but just partially:) actually it is not correct, because you have in Spring.Web.UI.UserControl:

public virtual CultureInfo UserLocale
{
get
{
if (Page is Spring.Web.UI.Page)
{
return ((Page) Page).UserLocale;
}
else
{
return Thread.CurrentThread.CurrentUICulture;
} }
}


What to do?

Lp
S

Aleks Seovic
10-24-2005, 01:24 AM
I'm not sure I understand the problem...

All of the localization related stuff happens on the server, so which browser you use *shouldn't* have any effect.

BTW, you might want to get latest code from the CVS as the number of localization-related things changed, including some of the names (UserLocale is UserCulture now, for example, to be more .NET-ish).

Later,

Aleks

sebastijanp
10-24-2005, 02:10 AM
I wiil get the latest version ok.
But still, Have you tried to see UserLocale.TwoLetterISOLanguageName in Mozilla Firefox?

I was thinking the same as you did. every thing happens on server. I wrote the value UserLocale.TwoLetterISOLanguageName with log4net.

On my machine it should be "sl" (Slovenian). If I run the application in IE, everything is correct. But if I run it in Firefox, UserLocale.TwoLetterISOLanguageName returns "en". Which is not correct.
But System.Threading.Thread.CurrentThread.CurrentCultu re.TwoLetterISOLanguageName
IS "sl".

I use that value do decide which menu (English, Slovenian,...) will I show, when I change the languge with a click on for example English version of page.
I can create an example project if needed?...

Lp
S

Aleks Seovic
10-24-2005, 04:46 AM
Which locale/culture resolver implementation are you using?

If you don't configure one explicitly, default resolver will set UserLocale to the value of the first Accept-Lang request header. Values for this header can be configured in IE under Internet Options -> Languages (button), and by default it is set to the OS locale (I believe).

Not sure how you would configure the same thing in Firefox, but you should be able to. Another option is to switch to SessionCultureResolver or CookieCultureResolver and to set the value within your application.

Again, it's hard to tell anything else without knowing which version of Spring.Web you are using. Probably the best course of action is that you upgrade to the latest code from CVS, refactor your application to use renamed classes and properties and then see what happens. That way we can at least work with the same version of the framework, which helps ;-)

BTW, you should probably reread localization docs on the wiki, to have an idea what has changed and what was added in the last couple of weeks (hint -- a lot ;))

Later,

Aleks