views:

120

answers:

1

Hi,

In asp.net multilingual website in english Uk and swedish, i have three rsources file

1. en-GB.resx
2. sv-SE.resx
3. Culture neutral file.

I have create one base class and all pages is inherited from that class. There i write following lines to set UICULTURE and culture

1. Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture.Name;
2. Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture.Name;

Question: Suppose my browser language is Swedish(sv-SE) then this code will run because it find CurrentUICulture and CurrentCulture values as sv-SE.

Now if suppose browser language is Swedish(sv) only, in that case values will be set as

CurrentUICulture = sv; and CurrentCulture = sv-SE

Now the problem is that user can able to view all text in Culture neutral resource file that i kept as english while all decimal saperators, currency and other will be appear in swedish. It looks confusing to usr.

What would be right approach. I am thinking following solution. Please correct me?

1. i can create extra resource file for sv also.
2. I check value of CurrentUICulture in base class and if it is sv then replace it with sv-SE

Please correct me which one is right approach or Is there any other good way of doing?

+1  A: 

You can easily replace the value in the base class like you mentioned. I would stay away from creating an additional resource file that duplicates data since it will be harder to maintain.

 if (Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower() != "sv")
      ...replace with sv-SE

EDIT See this other question]1 for additional info. There's a good article referenced in the answer of that question

tzup
I think no need to check also. because already we have sv-SE with CultureInfo.CurrentCulture.Name; and i can assign this value for both like this way1. Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture.Name; 2. Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture.NameWhat do you say?
Hemant Kothiyal
You can definitely do this if you don't need to have numbers in one culture and text in another.
tzup