Beispiel #1
0
        protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
            string     lang       = null;
            HttpCookie langCookie = Request.Cookies["culture"];

            if (langCookie != null)
            {
                lang = langCookie.Value;
            }
            else
            {
                var userLanguage = Request.UserLanguages;
                var userLang     = userLanguage != null ? userLanguage[0] : "";
                if (userLang != "")
                {
                    lang = userLang;
                }
                else
                {
                    lang = SiteLanguage.getDefaultLanguage();
                }
            }

            new SiteLanguage().setLanguage(lang);

            return(base.BeginExecuteCore(callback, state));
        }
Beispiel #2
0
        protected override void Initialize(RequestContext requestContext)
        {
            if (requestContext.RouteData.Values["lang"] != null && requestContext.RouteData.Values["lang"] as string != "null")
            {
                CurrentLangCode = requestContext.RouteData.Values["lang"] as string;

                switch (CurrentLangCode)
                {
                    case "ru":
                        CurrentLang = SiteLanguage.ru;
                        break;
                    case "ua":
                        CurrentLang = SiteLanguage.ua;
                        break;
                    case "en":
                        CurrentLang = SiteLanguage.en;
                        break;
                    default:
                        CurrentLang = SiteLanguage.ru;
                        break;
                }

                ViewBag.Locale = CurrentLangCode;

                var ci = new CultureInfo(CurrentLangCode == "ua" ? "uk" : CurrentLangCode);
                Thread.CurrentThread.CurrentUICulture = ci;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);
            }

            base.Initialize(requestContext);
        }
Beispiel #3
0
 public static void SetLanguages()
 {
     using (MySqlConnection conn = new MySqlConnection(cmstrDefualts.ConnStr))
     {
         conn.Open();
         string          sql = "Select LangID,LangName,LandDir,LangIcon,LangCulture From languages";
         MySqlCommand    cmd = new MySqlCommand(sql, conn);
         MySqlDataReader dr  = cmd.ExecuteReader();
         while (dr.Read())
         {
             SiteLanguage mylanguage = new SiteLanguage();
             int          myid       = 0;
             int.TryParse(dr["LangID"].ToString(), out myid);
             mylanguage.LangID      = myid;
             mylanguage.LangName    = dr["LangName"].ToString();
             mylanguage.LangIcon    = dr["LangIcon"].ToString();
             mylanguage.LandDir     = dr["LandDir"].ToString();
             mylanguage.LangCulture = dr["LangCulture"].ToString();
             languagesList.Add(mylanguage);
         }
         dr.Close();
         if (languagesList.Count == 0)
         {
             SiteLanguage mylanguage = new SiteLanguage();
             mylanguage.LangID      = 1;
             mylanguage.LangName    = "עברית";
             mylanguage.LangIcon    = "";
             mylanguage.LandDir     = "rtl";
             mylanguage.LangCulture = "heb";
             languagesList.Add(mylanguage);
         }
     }
 }
Beispiel #4
0
        public static string GetString(string key, SiteLanguage language)
        {
            string value;

            switch (language)
            {
            case SiteLanguage.Turkish:
                value = Strings.ResourceManager.GetString(key, turkishCultureInfo);
                break;

            case SiteLanguage.English:
            default:
                value = Strings.ResourceManager.GetString(key, englishCultureInfo);
                break;
            }

            if (string.IsNullOrEmpty(value))
            {
                // TO DO: Log
                return(string.Format("[{0}]", key));
            }
            else
            {
                return(value);
            }
        }
Beispiel #5
0
        public static string GetString(string key, SiteLanguage language)
        {
            string value;

            switch (language)
            {
                case SiteLanguage.Turkish:
                    value = Strings.ResourceManager.GetString(key, turkishCultureInfo);
                    break;
                case SiteLanguage.English:
                default:
                    value = Strings.ResourceManager.GetString(key, englishCultureInfo);
                    break;
            }

            if (string.IsNullOrEmpty(value))
            {
                // TO DO: Log
                return string.Format("[{0}]", key);
            }
            else
            {
                return value;
            }
        }
Beispiel #6
0
        internal string getLanguage(SiteLanguage siteLanguage)
        {
            string lang = "en";

            switch (siteLanguage)
            {
            case SiteLanguage.Chinese:
                lang = "zh";
                break;

            case SiteLanguage.English:
                lang = "en";
                break;

            case SiteLanguage.French:
                lang = "fr";
                break;

            case SiteLanguage.German:
                lang = "de";
                break;

            case SiteLanguage.Italian:
                lang = "it";
                break;

            case SiteLanguage.Japanese:
                lang = "ja";
                break;

            case SiteLanguage.Polish:
                lang = "pl";
                break;

            case SiteLanguage.Portuguese:
                lang = "pt";
                break;

            case SiteLanguage.Russian:
                lang = "ru";
                break;

            case SiteLanguage.Spanish:
                lang = "es";
                break;

            case SiteLanguage.Swedish:
                lang = "sv";
                break;

            case SiteLanguage.Turkish:
                lang = "tr";
                break;
            }
            return(lang);
        }
Beispiel #7
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">A <see cref="SiteLanguage"/></param>
        /// <returns>A <see cref="string"/></returns>
        public string GetURL(SiteLanguage language)
        {
            var url = ((XmlElement)GetNode()).GetElementsByTagName("url")[0].InnerText;

            var domain = GetSiteDomain(language);

            url = url.Substring(url.IndexOf("user/"));

            return($"http://{domain}/{url}");
        }
Beispiel #8
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">
        /// A <see cref="SiteLanguage"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string GetURL(SiteLanguage language)
        {
            string url = ((XmlElement)getNode()).GetElementsByTagName("url")[0].InnerText;

            string domain = getSiteDomain(language);

            url = url.Substring(url.IndexOf("user/"));

            return("http://" + domain + "/" + url);
        }
Beispiel #9
0
        internal string getSiteDomain(SiteLanguage language)
        {
            Dictionary <SiteLanguage, string> domains = new Dictionary <SiteLanguage, string>();

            domains.Add(SiteLanguage.English, "www.last.fm");
            domains.Add(SiteLanguage.German, "www.lastfm.de");
            domains.Add(SiteLanguage.Spanish, "www.lastfm.es");
            domains.Add(SiteLanguage.French, "www.lastfm.fr");
            domains.Add(SiteLanguage.Italian, "www.lastfm.it");
            domains.Add(SiteLanguage.Polish, "www.lastfm.pl");
            domains.Add(SiteLanguage.Portuguese, "www.lastfm.com.br");
            domains.Add(SiteLanguage.Swedish, "www.lastfm.se");
            domains.Add(SiteLanguage.Turkish, "www.lastfm.com.tr");
            domains.Add(SiteLanguage.Russian, "www.lastfm.ru");
            domains.Add(SiteLanguage.Japanese, "www.lastfm.jp");
            domains.Add(SiteLanguage.Chinese, "cn.last.fm");

            return(domains[language]);
        }
Beispiel #10
0
        internal string GetSiteDomain(SiteLanguage language)
        {
            var domains = new Dictionary <SiteLanguage, string>
            {
                { SiteLanguage.English, "www.last.fm" },
                { SiteLanguage.German, "www.lastfm.de" },
                { SiteLanguage.Spanish, "www.lastfm.es" },
                { SiteLanguage.French, "www.lastfm.fr" },
                { SiteLanguage.Italian, "www.lastfm.it" },
                { SiteLanguage.Polish, "www.lastfm.pl" },
                { SiteLanguage.Portuguese, "www.lastfm.com.br" },
                { SiteLanguage.Swedish, "www.lastfm.se" },
                { SiteLanguage.Turkish, "www.lastfm.com.tr" },
                { SiteLanguage.Russian, "www.lastfm.ru" },
                { SiteLanguage.Japanese, "www.lastfm.jp" },
                { SiteLanguage.Chinese, "cn.last.fm" }
            };

            return(domains[language]);
        }
Beispiel #11
0
    public static SiteLanguage GetLanguage()
    {
        int          sitelang = 0;
        SiteLanguage myLang   = new SiteLanguage();

        if (HttpContext.Current.Request.QueryString["sitelang"] != null && int.TryParse(HttpContext.Current.Request.QueryString["sitelang"].ToString(), out sitelang))
        {
            myLang = SiteLanguage.languagesList.FirstOrDefault(m => m.LangID == sitelang);
            HttpContext.Current.Session["SiteLang"] = sitelang.ToString();
        }
        else if (HttpContext.Current.Session["SiteLang"] != null && int.TryParse(HttpContext.Current.Session["SiteLang"].ToString(), out sitelang))
        {
            myLang = SiteLanguage.languagesList.FirstOrDefault(m => m.LangID == sitelang);
        }
        else
        {
            if (SiteLanguage.languagesList.Count > 0)
            {
                myLang = SiteLanguage.languagesList[0];
                HttpContext.Current.Session["SiteLang"] = myLang.LangID;
            }
        }
        return(myLang);
    }
Beispiel #12
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">
        /// A <see cref="SiteLanguage"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string GetURL(SiteLanguage language)
        {
            string domain = getSiteDomain(language);

            return("http://" + domain + "/music/" + urlSafe(Artist.Name) + "/" + urlSafe(Name));
        }
Beispiel #13
0
 public Session(string apiKey, string apiSecret, SiteLanguage siteLanguage = SiteLanguage.English)
 {
     ApiKey            = apiKey;
     ApiSecret         = apiSecret;
     this.SiteLanguage = siteLanguage;
 }
Beispiel #14
0
 public static void SetLanguage(SiteLanguage language)
 {
     siteLanguage       = language;
     currentCultureInfo = new CultureInfo((int)language);
 }
Beispiel #15
0
 /// <summary>
 /// Returns the Last.fm page of this object.
 /// </summary>
 /// <param name="language">
 /// A <see cref="SiteLanguage"/>
 /// </param>
 /// <returns>
 /// A <see cref="System.String"/>
 /// </returns>
 public string GetURL(SiteLanguage language)
 {
     return(User.GetURL(language) + "/library");
 }
Beispiel #16
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">A <see cref="SiteLanguage"/></param>
        /// <returns>A <see cref="string"/></returns>
        public string GetURL(SiteLanguage language)
        {
            var domain = GetSiteDomain(language);

            return($"http://{domain}/music/{UrlSafe(Artist.Name)}/_/{UrlSafe(Title)}");
        }
Beispiel #17
0
		/// <summary>
		/// Returns the Last.fm page of this object.
		/// </summary>
		/// <param name="language">
		/// A <see cref="SiteLanguage"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.String"/>
		/// </returns>
		public string GetURL(SiteLanguage language)
		{
			return Artist.GetURL(language) + "/+wiki";
		}
 public ActionResult ChangeLanguage(string lang)
 {
     SiteLanguage.SetLanguage(lang);
     return(RedirectToAction("NewRegistration"));
 }
Beispiel #19
0
		/// <summary>
		/// Retursn the object's Last.fm page url.
		/// </summary>
		/// <param name="language">
		/// A <see cref="SiteLanguage"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.String"/>
		/// </returns>
		public string GetURL(SiteLanguage language)
		{
			return Track.GetURL(language) + "/+wiki";
		}
Beispiel #20
0
 /// <summary>
 /// Returns the Last.fm page of this object.
 /// </summary>
 /// <param name="language">A <see cref="SiteLanguage"/></param>
 /// <returns>A <see cref="string"/></returns>
 private string GetURL(SiteLanguage language)
 {
     return($"{Artist.GetURL(language)}/+wiki");
 }
Beispiel #21
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">
        /// A <see cref="SiteLanguage"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string GetURL(SiteLanguage language)
        {
            string domain = getSiteDomain(language);

            return("http://" + domain + "/event/" + ID.ToString());
        }
Beispiel #22
0
 public static void SetLanguage(SiteLanguage language)
 {
     siteLanguage = language;
     currentCultureInfo = new CultureInfo((int)language);
 }
 public ActionResult ChangeLanguage(string lang)
 {
     SiteLanguage.SetLanguage(lang);
     return(RedirectToAction("SignIn", "Login"));
 }
		/// <summary>
		/// Returns the Last.fm page of this object.
		/// </summary>
		/// <param name="language">
		/// A <see cref="SiteLanguage"/>
		/// </param>
		/// <returns>
		/// A <see cref="System.String"/>
		/// </returns>
		public string GetURL(SiteLanguage language)
		{	
			return User.GetURL(language) + "/library";
		}
        /// <summary>
        /// Returns the country's page url on Last.fm.
        /// </summary>
        /// <param name="language">
        /// A <see cref="SiteLanguage"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string GetURL(SiteLanguage language)
        {
            string domain = getSiteDomain(language);

            return "http://" + domain + "/place/" + urlSafe(Name);
        }
Beispiel #26
0
 /// <summary>
 /// Retursn the object's Last.fm page url.
 /// </summary>
 /// <param name="language">A <see cref="SiteLanguage"/></param>
 /// <returns>A <see cref="string"/></returns>
 public string GetURL(SiteLanguage language)
 {
     return($"{Track.GetURL(language)}/+wiki");
 }
Beispiel #27
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">
        /// A <see cref="SiteLanguage"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/>
        /// </returns>
        public string GetURL(SiteLanguage language)
        {
            string domain = getSiteDomain(language);

            return("http://" + domain + "/user/" + urlSafe(Name));
        }
Beispiel #28
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">A <see cref="SiteLanguage"/></param>
        /// <returns>A <see cref="string"/></returns>
        public string GetURL(SiteLanguage language)
        {
            var domain = GetSiteDomain(language);

            return($"http://{domain}/event/{ID.ToString()}");
        }
Beispiel #29
0
 /// <summary>
 /// Returns the Last.fm page of this object.
 /// </summary>
 /// <param name="language">
 /// A <see cref="SiteLanguage"/>
 /// </param>
 /// <returns>
 /// A <see cref="System.String"/>
 /// </returns>
 public string GetURL(SiteLanguage language)
 {
     return(Album.GetURL(language) + "/+wiki");
 }
Beispiel #30
0
        /// <summary>
        /// Returns the Last.fm page of this object.
        /// </summary>
        /// <param name="language">A <see cref="SiteLanguage"/></param>
        /// <returns>A <see cref="string"/></returns>
        public string GetURL(SiteLanguage language)
        {
            var domain = GetSiteDomain(language);

            return($"http://{domain}/user/{UrlSafe(Name)}");
        }