Rank: Newbie Groups: Member
Joined: 9/23/2009 Posts: 8
|
I am using the spellchecker and I notice that when I set my browser's language to a language that does not have a dictionary, my web site crashes when I start the spell checker. For now, I've added a couple of appSettings to my web.config file that define a default language and the supported languages, as follows.
<add key="DefaultLanguage" value="en-US"/> <add key="SupportedLanguages" value="en,fr"/>
Then when I create an instance of my spell checker, I perform the following logic.
string[] langs = WebConfigurationManager.AppSettings["SupportedLanguages"].Split(",".ToCharArray()); bool fLangFound = false; if (langs.Length > 0) { string[] browserLangs = Request.UserLanguages; foreach(string lang in langs) { if (browserLangs[0].ToLower().Contains(lang)) { fLangFound = true; break; } } } if (!fLangFound) spellChecker.Language = WebConfigurationManager.AppSettings["DefaultLanguage"];
Is there a better way?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Unforunately no. There isn't a better way. The code throws an exception on purpose when the folder doesn't exist so that you will be made aware of that you actually do not have the dictionary files. This avoid situation where everybody though it's working but actually it is not.
Thanks
|