From 07e76a4fefd2c868cafb6874a7b899b333f73342 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 14 Feb 2019 12:13:56 +0300 Subject: [PATCH] r7: remove language selector --- .../Web/App_Code/BasePage.cs | 14 +- .../Web/App_Code/Classes/DocHelpParcing.cs | 35 +-- .../Web/App_Code/Classes/LanguageProvider.cs | 233 ------------------ .../Common/BaseHeader/BaseHeader.ascx | 3 +- .../Web/Controls/Common/LanguageSelector.ascx | 17 -- .../Web/Masters/BaseMaster.master | 28 +-- .../Web/Masters/HelpCenter.master | 12 - helpcenter.r7-office.ru/Web/Search.aspx | 2 +- 8 files changed, 8 insertions(+), 336 deletions(-) delete mode 100644 helpcenter.r7-office.ru/Web/App_Code/Classes/LanguageProvider.cs delete mode 100644 helpcenter.r7-office.ru/Web/Controls/Common/LanguageSelector.ascx diff --git a/helpcenter.r7-office.ru/Web/App_Code/BasePage.cs b/helpcenter.r7-office.ru/Web/App_Code/BasePage.cs index a15c3b4af..858f11388 100644 --- a/helpcenter.r7-office.ru/Web/App_Code/BasePage.cs +++ b/helpcenter.r7-office.ru/Web/App_Code/BasePage.cs @@ -17,18 +17,6 @@ using System.Text; /// public class BasePage : Page { - #region Teamlab UI Culture - - public CultureInfo TeamLabUICulture - { - get - { - return LanguageProvider.GetCurrentCulture(); - } - } - - #endregion - private static Dictionary> m_contentExists = new Dictionary>(); private static object lockObj = new object(); @@ -63,7 +51,7 @@ public class BasePage : Page public string GetContentFileName(string contentName, bool isVirtualPath) { - string cultureKey = TeamLabUICulture.TwoLetterISOLanguageName; + string cultureKey = "ru"; string result; bool exists = (String.Compare( ConfigurationManager.AppSettings["cache-loc-content-filenames"], diff --git a/helpcenter.r7-office.ru/Web/App_Code/Classes/DocHelpParcing.cs b/helpcenter.r7-office.ru/Web/App_Code/Classes/DocHelpParcing.cs index 7d7091ca7..0d609cda8 100644 --- a/helpcenter.r7-office.ru/Web/App_Code/Classes/DocHelpParcing.cs +++ b/helpcenter.r7-office.ru/Web/App_Code/Classes/DocHelpParcing.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; +using System.Configuration; +using System.IO; using System.Linq; +using System.Net; using System.Web; using HtmlAgilityPack; -using System.Net; -using System.IO; -using System.Configuration; -using System.Web.UI; public static class DocHelpParcing { @@ -149,32 +148,6 @@ public static class DocHelpParcing private static String GetLanguage() { - var lng = LanguageProvider.GetCurrentCulture().ToString(); - string language; - switch (lng) - { - case "fr-FR": - language = "fr"; - break; - case "it-IT": - language = "it"; - break; - case "de-DE": - language = "de"; - break; - case "es-ES": - language = "es"; - break; - case "ru-RU": - language = "ru"; - break; - case "lv-LV": - language = "lv"; - break; - default: - language = "ru"; - break; - } - return language; + return "ru"; } } diff --git a/helpcenter.r7-office.ru/Web/App_Code/Classes/LanguageProvider.cs b/helpcenter.r7-office.ru/Web/App_Code/Classes/LanguageProvider.cs deleted file mode 100644 index 92efcc7b3..000000000 --- a/helpcenter.r7-office.ru/Web/App_Code/Classes/LanguageProvider.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Web; -using ASC.TeamlabSite.MultiRegionHelper; - -public static class LanguageProvider -{ - private const string SELECTED = "culture.selected"; - - private static readonly Dictionary cultureUiMap = new Dictionary() - { - { "", CultureInfo.GetCultureInfo("en-US") }, - { "fr", CultureInfo.GetCultureInfo("fr-FR") }, - { "es", CultureInfo.GetCultureInfo("es-ES") }, - { "de", CultureInfo.GetCultureInfo("de-DE") }, - { "ru", CultureInfo.GetCultureInfo("ru-RU") }, - { "lv", CultureInfo.GetCultureInfo("lv-LV") }, - }; - - private static readonly Dictionary timeZones = new Dictionary() - { - { "", TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time") }, - { "fr", TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time") }, - { "es", TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time")}, - { "de", TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time") }, - { "ru", TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time") }, - { "lv", TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time") }, - }; - - - static LanguageProvider() - { - try - { - var languages = ConfigurationManager.AppSettings["locale-enabled"]; - if (!string.IsNullOrEmpty(languages)) - { - cultureUiMap = new Dictionary { { "", CultureInfo.GetCultureInfo("en-US") } }; - languages - .Split(',', ';') - .Select(x => x.Trim()) - .ToList() - .ForEach(ln => cultureUiMap.Add(ln.Substring(0, 2), CultureInfo.GetCultureInfo(ln))); - } - } - catch { } - } - - - public static IDictionary GetAvailibleLanguages() - { - return cultureUiMap.ToDictionary(key => MakeUrl(key.Key), value => value.Value); - } - - public static IDictionary GetAvailibleLanguagesName() - { - var result = new Dictionary(); - cultureUiMap.ToList().ForEach(el => result.Add(el.Key, el.Value.DisplayName)); - return result; - } - - public static string GetLanguageName(CultureInfo culture) - { - try - { - //capitalize - return char.ToUpper(culture.NativeName[0]) + culture.NativeName.Substring(1); - } - catch { } - return string.Empty; - } - - public static CultureInfo GetCurrentCulture() - { - if (HttpContext.Current != null) - { - var _log = log4net.LogManager.GetLogger("ASC.LanguageProvider"); - if (HttpContext.Current.Items[SELECTED] == null || !(HttpContext.Current.Items[SELECTED] is CultureInfo)) - { - _log.Debug("HttpContext.Current.Items[SELECTED] == null || !(HttpContext.Current.Items[SELECTED] is CultureInfo = TRUE"); - if (string.IsNullOrEmpty(GetCultureKey())) - { - _log.Debug("HttpContext.Current.Items[SELECTED] == null || !(HttpContext.Current.Items[SELECTED] is CultureInfo = TRUE"); - if (HttpContext.Current.Session != null && HttpContext.Current.Session["redirected"] == null) - { - _log.Debug("HttpContext.Current.Session['redirected'] = null"); - try - { - var currentIPGeo = MultiRegionHelper.Instance.GetIPGeolocationInfoFull(); - var priorityLng = currentIPGeo.Lang; - if (!String.IsNullOrEmpty(priorityLng)) { - var acceptLng = HttpContext.Current.Request.Headers["Accept-Language"]; - if (!string.IsNullOrEmpty(acceptLng)) - { - try - { - var priorityLngs = acceptLng.Split(',') - .Select(x => x.Split(';').FirstOrDefault()) - .Where(x => !string.IsNullOrEmpty(x)).Select(x => x.Split('-').FirstOrDefault()) - .Select(x => "en".Equals(x, StringComparison.OrdinalIgnoreCase) ? string.Empty : x); - if (priorityLngs.Any()) - { - priorityLng = priorityLngs.Where(x => x != null && cultureUiMap.ContainsKey(x)).FirstOrDefault(); - } - } - catch (Exception ex) - { - _log.Error(ex); - } - } - } - _log.Debug("priorityLng = " + priorityLng); - - if (!String.IsNullOrEmpty(priorityLng) && cultureUiMap.ContainsKey(priorityLng)) - { - if (HttpContext.Current.Session != null) - HttpContext.Current.Session["redirected"] = true; - var newUrl = MakeUrl(priorityLng); - _log.Debug("newUrl = " + newUrl); - - HttpContext.Current.Response.Redirect(newUrl, false); - HttpContext.Current.Response.Clear(); - HttpContext.Current.ApplicationInstance.CompleteRequest(); - } - } - catch (Exception ex) - { - _log.Error(ex); - } - } - } - - string cultureKey = GetCultureKey() ?? string.Empty; - _log.Debug("130. cultureKey = " + cultureKey); - if (cultureUiMap.ContainsKey(cultureKey)) - { - var culture = cultureUiMap[cultureKey]; - HttpContext.Current.Items[SELECTED] = culture; - return culture; - } - } - else - { - return (CultureInfo)HttpContext.Current.Items[SELECTED]; - } - } - return CultureInfo.CurrentUICulture; - } - - private static string GetCultureKey() - { - var cultureKey = string.Empty; - if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["locale-mod"])) - { - cultureKey = HttpContext.Current.Request[ConfigurationManager.AppSettings["locale-mod"]]; - } - else - { - //Try select from request - if (HttpContext.Current.Request.ApplicationPath != null) - { - cultureKey = HttpContext.Current.Request.ApplicationPath.TrimStart('/'); - } - } - return cultureKey; - } - - private static string MakeUrl(string lngKey) - { - if (HttpContext.Current != null && HttpContext.Current.Request != null) - { - //get request url - var request = HttpContext.Current.Request; - var url = request.Url; - if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["locale-mod"])) - { - var lngQueryKey = ConfigurationManager.AppSettings["locale-mod"]; - url = new Uri(url, url.AbsolutePath + SetUrlParam(lngQueryKey, lngKey, request.QueryString)); - } - else - { - //Based on app path - if (request.ApplicationPath != null) - { - var urlApp = "/" + string.Format("/{0}/{1}", lngKey, request.Url.PathAndQuery.Substring(request.ApplicationPath.Length).TrimStart('/')).TrimStart('/'); - url = new Uri(url, urlApp); - } - } - return url.ToString(); - } - return string.Empty; - } - - private static string SetUrlParam(string param, string value, NameValueCollection queryStringOriginal) - { - var queryString = new NameValueCollection(queryStringOriginal); - if (!string.IsNullOrEmpty(value)) - { - if (!string.IsNullOrEmpty(queryString[param])) - { - queryString[param] = value; - } - else - { - queryString.Add(param, value); - } - } - else - { - //Remove value - queryString.Remove(param); - } - var query = new StringBuilder(); - if (queryString.Count > 0) - { - query.Append("?"); - foreach (var key in queryString.AllKeys) - { - if (!string.IsNullOrEmpty(queryString[key])) - { - query.AppendFormat("{0}={1}&", HttpUtility.UrlPathEncode(key), HttpUtility.UrlPathEncode(queryString[key])); - } - } - } - return query.ToString().TrimEnd('&'); - } - -} diff --git a/helpcenter.r7-office.ru/Web/Controls/Common/BaseHeader/BaseHeader.ascx b/helpcenter.r7-office.ru/Web/Controls/Common/BaseHeader/BaseHeader.ascx index 85dadab75..49326a9f5 100644 --- a/helpcenter.r7-office.ru/Web/Controls/Common/BaseHeader/BaseHeader.ascx +++ b/helpcenter.r7-office.ru/Web/Controls/Common/BaseHeader/BaseHeader.ascx @@ -1,6 +1,5 @@ <%@ Control Language="C#" %> -<%@ Register Src="~/Controls/Common/LanguageSelector.ascx" TagName="LangSelector" TagPrefix="uc" %> -<%@ Register Namespace="TeamLab.Controls" Assembly="__Code" TagPrefix="cc" %> +