/// <summary>
        /// Get current Language from User language list
        /// </summary>
        /// <param name="myLanguagesCultureList"></param>
        /// <returns></returns>
        private static LanguageCultureItem InternalGetUserLanguages(LanguageCultureCollection myLanguagesCultureList)
        {
            //Get userLangs
            CultureInfo[] userLangs;

            if (HttpContext.Current != null && HttpContext.Current.Request.UserLanguages != null &&
                HttpContext.Current.Request.UserLanguages.Length > 0)
            {
                ArrayList arrUserLangs = new ArrayList(HttpContext.Current.Request.UserLanguages);
                if (arrUserLangs.Count > 0)
                {
                    for (Int32 i = 0; i <= arrUserLangs.Count - 1; i++)
                    {
                        string currentLanguage;
                        if (arrUserLangs[i].ToString().IndexOf(';') >= 0)
                        {
                            currentLanguage =
                                arrUserLangs[i].ToString().Substring(0, arrUserLangs[i].ToString().IndexOf(';'));
                        }
                        else
                        {
                            currentLanguage = arrUserLangs[i].ToString();
                        }
                        try
                        {
                            // We try the full one... if this fails we catch it
                            arrUserLangs[i] = new CultureInfo(currentLanguage);
                        }
                        catch (ArgumentException)
                        {
                            try
                            {
                                // Some browsers can send an invalid language
                                // we try to get first two letters.. this is usually valid
                                arrUserLangs[i] = new CultureInfo(currentLanguage.Substring(2));
                            }
                            catch (ArgumentException)
                            {
                            }
                            return(null);
                        }
                    }
                }
                userLangs = (CultureInfo[])arrUserLangs.ToArray(typeof(CultureInfo));

                // Try to match browser "accept languages" list
                return(myLanguagesCultureList.GetBestMatching(userLangs));
            }
            return(null);
        }
 /// <summary>
 /// Get current Language from Querystring
 /// </summary>
 /// <param name="myLanguagesCultureList"></param>
 /// <returns></returns>
 private static LanguageCultureItem InternalGetQuerystring(LanguageCultureCollection myLanguagesCultureList)
 {
     if (HttpContext.Current != null && HttpContext.Current.Request.Params["Lang"] != null &&
         HttpContext.Current.Request.Params["Lang"].Length > 0)
     {
         try
         {
             return
                 (myLanguagesCultureList.GetBestMatching(
                      new CultureInfo(HttpContext.Current.Request.Params["Lang"])));
         }
         catch (ArgumentException) //Maybe an invalid CultureInfo
         {
             return(null);
         }
     }
     return(null);
 }
 /// <summary>
 /// Get current Language from Cookie
 /// </summary>
 /// <param name="myLanguagesCultureList"></param>
 /// <param name="cookieAlias"></param>
 /// <returns></returns>
 private static LanguageCultureItem InternalGetCookie(LanguageCultureCollection myLanguagesCultureList,
                                                      string cookieAlias)
 {
     if (HttpContext.Current != null && cookieAlias != null &&
         HttpContext.Current.Request.Cookies[SWITCHER_COOKIE_PREFIX + cookieAlias] != null &&
         HttpContext.Current.Request.Cookies[SWITCHER_COOKIE_PREFIX + cookieAlias].Value.Length > 0)
     {
         try
         {
             return
                 (myLanguagesCultureList.GetBestMatching(
                      new CultureInfo(
                          HttpContext.Current.Request.Cookies[SWITCHER_COOKIE_PREFIX + cookieAlias].Value)));
         }
         catch (ArgumentException)
         {
             //Maybe an invalid CultureInfo
         }
     }
     return(null);
 }