开发者

asp.net multiligual website culture settings

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 so开发者_StackOverflow中文版lution. 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜