Exemplo n.º 1
0
 public static void LocalizeDataGrid(DataGrid dataGrid, ILocalizationHelper localization)
 {
     foreach (DataGridColumn column in dataGrid.Columns)
     {
         var headerText = localization.GetString(column.HeaderText + ".HeaderText");
         if (!string.IsNullOrEmpty(headerText))
         {
             column.HeaderText = headerText;
         }
         var footerText = localization.GetString(column.FooterText + ".FooterText");
         if (!string.IsNullOrEmpty(footerText))
         {
             column.FooterText = footerText;
         }
     }
 }
Exemplo n.º 2
0
 public static void LocalizeGridView(GridView gridView, ILocalizationHelper localization)
 {
     foreach (DataControlField column in gridView.Columns)
     {
         var headerText = localization.GetString(column.HeaderText + ".HeaderText");
         if (!string.IsNullOrEmpty(headerText))
         {
             column.HeaderText = headerText;
         }
         var footerText = localization.GetString(column.FooterText + ".FooterText");
         if (!string.IsNullOrEmpty(footerText))
         {
             column.FooterText = footerText;
         }
     }
 }
Exemplo n.º 3
0
 public static void LocalizeRadGrid(RadGrid radGrid, ILocalizationHelper localization)
 {
     foreach (GridColumn column in radGrid.Columns)
     {
         var headerText = localization.GetString(column.UniqueName + ".HeaderText");
         if (!string.IsNullOrEmpty(headerText))
         {
             column.HeaderText = headerText;
         }
         var footerText = localization.GetString(column.UniqueName + ".FooterText");
         if (!string.IsNullOrEmpty(footerText))
         {
             column.FooterText = footerText;
         }
     }
 }
        public TopChangeInfoJson(TopChangeInfo topChangeInfo, ILocalizationHelper localization, int pageSize)
            : this()
        {
            TotalCount = topChangeInfo.TotalCount;

            var noChangeString = localization.GetString("NoChange");

            foreach (var topChangeItemInfo in topChangeInfo.Items)
            {
                var topChangeItemInfoJson = new TopChangeItemInfoJson
                {
                    ProductId   = topChangeItemInfo.ProductId,
                    ProductName = topChangeItemInfo.ProductName,
                    ProductUrl  =
                        string.Format("/DesktopModules/Hotcakes/Core/Admin/catalog/Products_Performance.aspx?id={0}",
                                      topChangeItemInfo.ProductId)
                };

                topChangeItemInfoJson.BouncesChange     = noChangeString;
                topChangeItemInfoJson.AbandomentsChange = noChangeString;
                topChangeItemInfoJson.PurchasesChange   = noChangeString;
                topChangeItemInfoJson.Change            = noChangeString;

                if (Math.Abs(topChangeItemInfo.BouncesChange) >= 0.01m)
                {
                    topChangeItemInfoJson.BouncesChange          = Math.Abs(topChangeItemInfo.BouncesChange).ToString("p0");
                    topChangeItemInfoJson.IsBouncesChangeGrowing = topChangeItemInfo.BouncesChange > 0;
                }

                if (Math.Abs(topChangeItemInfo.AbandomentsChange) >= 0.01m)
                {
                    topChangeItemInfoJson.AbandomentsChange =
                        Math.Abs(topChangeItemInfo.AbandomentsChange).ToString("p0");
                    topChangeItemInfoJson.IsAbandomentsChangeGrowing = topChangeItemInfo.AbandomentsChange > 0;
                }

                if (Math.Abs(topChangeItemInfo.PurchasesChange) >= 0.01m)
                {
                    topChangeItemInfoJson.PurchasesChange          = Math.Abs(topChangeItemInfo.PurchasesChange).ToString("p0");
                    topChangeItemInfoJson.IsPurchasesChangeGrowing = topChangeItemInfo.PurchasesChange > 0;
                }

                if (Math.Abs(topChangeItemInfo.Change) >= 0.01m)
                {
                    topChangeItemInfoJson.Change          = Math.Abs(topChangeItemInfo.Change).ToString("p0");
                    topChangeItemInfoJson.IsChangeGrowing = topChangeItemInfo.Change > 0;
                }

                Items.Add(topChangeItemInfoJson);
            }

            while (Items.Count < pageSize)
            {
                Items.Add(new TopChangeItemInfoJson());
            }
        }
Exemplo n.º 5
0
        public static string GetOrderShippingStatus(OrderShippingStatus shippingStatus, string culture = null)
        {
            var value = OrderShippingStatusesLocalization.GetFormattedString(shippingStatus.ToString(), culture);

            if (string.IsNullOrEmpty(value))
            {
                value = OrderShippingStatusesLocalization.GetString(OrderShippingStatus.Unknown.ToString(), culture);
            }
            return(value);
        }
Exemplo n.º 6
0
        public static string GetActionType(ActionType actionType, string methodName)
        {
            var value = ActionTypesLocalization.GetFormattedString(actionType.ToString(), methodName);

            if (string.IsNullOrEmpty(value))
            {
                value = ActionTypesLocalization.GetString(ActionType.Unknown.ToString());
            }
            return(value);
        }
Exemplo n.º 7
0
        public SalesInfoJson(SalesInfo info, ILocalizationHelper localization)
        {
            ChartLabels                  = info.ChartLabels;
            ChartData                    = info.ChartData;
            OrdersCount                  = info.OrdersCount;
            OrdersCompleted              = info.OrdersCompleted;
            OrdersAbandonedPercent       = info.OrdersAbandonedPercent;
            OrdersTotalSum               = Money.GetFriendlyAmount(info.OrdersTotalSum, CultureInfo.CurrentUICulture);
            OrdersSuccessfulTransactions = info.OrdersSuccessfulTransactions;

            var noChangeString = localization.GetString("NoChange");
            var salesByDeviceComparisonString = localization.GetString("SalesByDeviceComparison");

            var ci = CultureInfo.CurrentUICulture;

            SalesByDesktopCount      = info.SalesByDesktopCount;
            SalesByDesktopComparison = noChangeString;
            if (Math.Abs(info.SalesByDesktopPercent - info.SalesByDesktopPercentPrev) > 0.01m)
            {
                SalesByDesktopGrowing    = info.SalesByDesktopPercent > info.SalesByDesktopPercentPrev;
                SalesByDesktopComparison = string.Format(salesByDeviceComparisonString, info.SalesByDesktopPercent,
                                                         info.SalesByDesktopPercentPrev);
            }

            SalesByTabletCount      = info.SalesByTabletCount;
            SalesByTabletComparison = noChangeString;
            if (Math.Abs(info.SalesByTabletPercent - info.SalesByTabletPercentPrev) > 0.01m)
            {
                SalesByTabletGrowing    = info.SalesByTabletPercent > info.SalesByTabletPercentPrev;
                SalesByTabletComparison = string.Format(salesByDeviceComparisonString, info.SalesByTabletPercent,
                                                        info.SalesByTabletPercentPrev);
            }

            SalesByPhoneCount      = info.SalesByPhoneCount;
            SalesByPhoneComparison = noChangeString;
            if (Math.Abs(info.SalesByPhonePercent - info.SalesByPhonePercentPrev) > 0.01m)
            {
                SalesByPhoneGrowing    = info.SalesByPhonePercent > info.SalesByPhonePercentPrev;
                SalesByPhoneComparison = string.Format(salesByDeviceComparisonString, info.SalesByPhonePercent,
                                                       info.SalesByPhonePercentPrev);
            }
        }
Exemplo n.º 8
0
        public PerformanceInfoJson(PerformanceInfo performanceInfo, SalesPeriod period, ILocalizationHelper localization)
        {
            BouncedName   = localization.GetString("Bounced");
            AbandonedName = localization.GetString("Abandoned");
            PurchasedName = localization.GetString("Purchased");

            BouncedData   = performanceInfo.BouncedData;
            AbandonedData = performanceInfo.AbandonedData;
            PurchasedData = performanceInfo.PurchasedData;

            ChartLabels = performanceInfo.ChartLabels;
            Events      = performanceInfo.Events;

            Views      = performanceInfo.Views.ToString("N0");
            AddsToCart = performanceInfo.AddsToCart.ToString("N0");
            Purchases  = performanceInfo.Purchases.ToString("N0");

            var bouncesPercentageChange = 0D;

            if (performanceInfo.ViewsPrev != 0)
            {
                bouncesPercentageChange = Math.Abs(performanceInfo.Views - performanceInfo.ViewsPrev) /
                                          (double)performanceInfo.ViewsPrev;
            }
            else if (performanceInfo.Views != 0)
            {
                bouncesPercentageChange = 1;
            }
            bouncesPercentageChange = Math.Round(bouncesPercentageChange, 2);
            ViewsPercentageChange   = bouncesPercentageChange.ToString("p0");

            var abandomentsPercentageChange = 0D;

            if (performanceInfo.AddsToCartPrev != 0)
            {
                abandomentsPercentageChange = Math.Abs(performanceInfo.AddsToCart - performanceInfo.AddsToCartPrev) /
                                              (double)performanceInfo.AddsToCartPrev;
            }
            else if (performanceInfo.AddsToCart != 0)
            {
                abandomentsPercentageChange = 1;
            }
            abandomentsPercentageChange = Math.Round(abandomentsPercentageChange, 2);
            AddsToCartPercentageChange  = abandomentsPercentageChange.ToString("p0");

            var purchasesPercentageChange = 0D;

            if (performanceInfo.PurchasesPrev != 0)
            {
                purchasesPercentageChange = Math.Abs(performanceInfo.Purchases - performanceInfo.PurchasesPrev) /
                                            (double)performanceInfo.PurchasesPrev;
            }
            else if (performanceInfo.Purchases != 0)
            {
                purchasesPercentageChange = 1;
            }
            purchasesPercentageChange = Math.Round(purchasesPercentageChange, 2);
            PurchasesPercentageChange = purchasesPercentageChange.ToString("p0");

            var periodString = LocalizationUtils.GetSalesPeriodLower(period);
            var noChange     = localization.GetFormattedString("NoChangeSinceLast", periodString);
            var lessThan     = localization.GetFormattedString("LessSinceLast", periodString);
            var moreThan     = localization.GetFormattedString("MoreSinceLast", periodString);

            ViewsComparison = noChange;
            if (Math.Abs(bouncesPercentageChange) >= 0.01)
            {
                IsViewsGrowing  = performanceInfo.Views >= performanceInfo.ViewsPrev;
                ViewsComparison = IsViewsGrowing.Value ? moreThan : lessThan;
            }

            AddsToCartComparison = noChange;
            if (Math.Abs(abandomentsPercentageChange) >= 0.01)
            {
                IsAddsToCartGrowing  = performanceInfo.AddsToCart >= performanceInfo.AddsToCartPrev;
                AddsToCartComparison = IsAddsToCartGrowing.Value ? moreThan : lessThan;
            }

            PurchasesComparison = noChange;
            if (Math.Abs(purchasesPercentageChange) >= 0.01)
            {
                IsPurchasesGrowing  = performanceInfo.Purchases >= performanceInfo.PurchasesPrev;
                PurchasesComparison = IsPurchasesGrowing.Value ? moreThan : lessThan;
            }
        }
Exemplo n.º 9
0
 public static string GetGlobalResource(string key)
 {
     return(GlobalLocalization.GetString(key));
 }
Exemplo n.º 10
0
 public static string GetTaxProviderFriendlyName(string providerName)
 {
     return(TaxProvidersLocalization.GetString(providerName));
 }
Exemplo n.º 11
0
 public static string GetPaymentMethodFriendlyName(string methodName)
 {
     return(PaymentMethodsLocalization.GetString(methodName));
 }
Exemplo n.º 12
0
 public static string GetOrderStatus(string orderStatus, string culture = null)
 {
     return(OrderStatusesLocalization.GetString(orderStatus, culture));
 }
Exemplo n.º 13
0
        private void ProcessControl(Control control, ArrayList affectedControls, bool includeChildren,
                                    ILocalizationHelper localization)
        {
            if (!control.Visible)
            {
                return;
            }

            //Perform the substitution if a key was found
            var key = GetControlAttribute(control, affectedControls, ResourceKeyName);

            if (!string.IsNullOrEmpty(key))
            {
                //Translation starts here ....
                var value = localization.GetString(key);
                if (control is Label)
                {
                    var label = (Label)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        label.Text = value;
                    }
                }
                if (control is LinkButton)
                {
                    var linkButton = (LinkButton)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        var imgMatches = Regex.Matches(value,
                                                       "<(a|link|img|script|input|form).[^>]*(href|src|action)=(\\\"|'|)(.[^\\\"']*)(\\\"|'|)[^>]*>",
                                                       RegexOptions.IgnoreCase);
                        foreach (Match match in imgMatches)
                        {
                            if (match.Groups[match.Groups.Count - 2].Value.IndexOf("~", StringComparison.Ordinal) != -1)
                            {
                                var resolvedUrl = Page.ResolveUrl(match.Groups[match.Groups.Count - 2].Value);
                                value = value.Replace(match.Groups[match.Groups.Count - 2].Value, resolvedUrl);
                            }
                        }
                        linkButton.Text = value;
                        if (string.IsNullOrEmpty(linkButton.ToolTip))
                        {
                            linkButton.ToolTip = value;
                        }
                    }
                }
                if (control is HyperLink)
                {
                    var hyperLink = (HyperLink)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        hyperLink.Text = value;
                    }
                }
                if (control is ImageButton)
                {
                    var imageButton = (ImageButton)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        imageButton.AlternateText = value;
                    }
                }
                if (control is Button)
                {
                    var button = (Button)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        button.Text = value;
                    }
                }
                if (control is HtmlInputButton)
                {
                    var button = (HtmlInputButton)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        button.Value = value;
                    }
                }
                if (control is HtmlButton)
                {
                    var button = (HtmlButton)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        button.Attributes["Title"] = value;
                    }
                }
                if (control is HtmlImage)
                {
                    var htmlImage = (HtmlImage)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        htmlImage.Alt = value;
                    }
                }
                if (control is CheckBox)
                {
                    var checkBox = (CheckBox)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        checkBox.Text = value;
                    }
                    var toolTipValue = localization.GetString(key + ".ToolTip");
                    if (!string.IsNullOrEmpty(toolTipValue))
                    {
                        checkBox.ToolTip = toolTipValue;
                    }
                }
                if (control is BaseValidator)
                {
                    var baseValidator = (BaseValidator)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        baseValidator.Text = value;
                    }
                    var errorMessageValue = localization.GetString(key + ".ErrorMessage");
                    if (!string.IsNullOrEmpty(errorMessageValue))
                    {
                        baseValidator.ErrorMessage = errorMessageValue;
                    }
                }
                if (control is Image)
                {
                    var image = (Image)control;
                    if (!string.IsNullOrEmpty(value))
                    {
                        image.AlternateText = value;
                        image.ToolTip       = value;
                    }
                }
            }

            //Translate listcontrol items here
            if (control is ListControl)
            {
                var listControl = (ListControl)control;
                for (var i = 0; i <= listControl.Items.Count - 1; i++)
                {
                    var attributeCollection = listControl.Items[i].Attributes;
                    key = attributeCollection[ResourceKeyName];
                    if (key != null)
                    {
                        var value = localization.GetString(key);
                        if (!string.IsNullOrEmpty(value))
                        {
                            listControl.Items[i].Text = value;
                        }
                    }
                    if (key != null && affectedControls != null)
                    {
                        affectedControls.Add(attributeCollection);
                    }
                }
            }

            // translate table control header cells
            if (control is Table)
            {
                var table = (Table)control;
                foreach (var row in table.Rows)
                {
                    if (row is TableHeaderRow)
                    {
                        var thr = (TableHeaderRow)row;
                        foreach (var cell in thr.Cells)
                        {
                            var thc = (TableHeaderCell)cell;
                            var attributeCollection = thc.Attributes;
                            key = attributeCollection[ResourceKeyName];
                            if (key != null)
                            {
                                var value = localization.GetString(key);
                                if (!string.IsNullOrEmpty(value))
                                {
                                    thc.Text = value;
                                }
                            }
                        }

                        return;
                    }
                }
            }

            //Process child controls
            if (includeChildren && control.HasControls())
            {
                var hccUserControl = control as HccUserControl;
                if (hccUserControl == null)
                {
                    //Pass Resource File Root through
                    IterateControls(control.Controls, affectedControls, localization);
                }
                else
                {
                    //Get Resource File Root from Controls LocalResourceFile Property
                    IterateControls(control.Controls, affectedControls, hccUserControl.Localization);
                }
            }
        }