protected void updateButton_Click(object sender, EventArgs e)
        {
            var tabCtrl = new TabController();
            var portalCtrl = new PortalController();
            var locale = LocaleController.Instance.GetLocale(Locale);
            List<TabInfo> pageList = GetTabsToLocalize(PortalId, Locale);

            int scriptTimeOut = Server.ScriptTimeout;
            Server.ScriptTimeout = timeout;

            //add translator role
            Localization.AddTranslatorRole(PortalId, locale);

            //populate pages
            ProcessLanguage(pageList, locale, 0, 1);

            //Map special pages
            portalCtrl.MapLocalizedSpecialPages(PortalSettings.PortalId, locale.Code);

            //clear cache
            DataCache.ClearPortalCache(PortalId, true);

            //Restore Script Timeout
            Server.ScriptTimeout = scriptTimeOut;
            //'Redirect to refresh page (and skinobjects)
            Response.Redirect(Globals.NavigateURL(), true);
        }
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserInfo.IsSuperUser)
                {
                    //Update Language
                    if (Language == null)
                    {
                        _Language = LocaleController.Instance.GetLocale(languageComboBox.SelectedValue);
                        if (_Language == null)
                        {
                            _Language = new Locale();
                            Language.Code = languageComboBox.SelectedValue;
                        }
                    }
                    Language.Fallback = fallBackComboBox.SelectedValue;
                    Language.Text = CultureInfo.CreateSpecificCulture(Language.Code).NativeName;
                    Localization.SaveLanguage(Language);
                }

                if (!IsLanguageEnabled(Language.Code))
                {
                    //Add language to portal
                    Localization.AddLanguageToPortal(PortalId, Language.LanguageId, true);
                }

                string roles = Null.NullString;
                if (IsAddMode)
                {
                    roles = string.Format("Administrators;{0}", string.Format("Translator ({0})", Language.Code));
                }
                else
                {
                    foreach (string role in translatorRoles.SelectedRoleNames)
                    {
                        roles += role + ";";
                    }

                    roles = roles.TrimEnd(';');
                }

                PortalController.UpdatePortalSetting(PortalId, string.Format("DefaultTranslatorRoles-{0}", Language.Code), roles);

                var tabCtrl = new TabController();
                TabCollection tabs = tabCtrl.GetTabsByPortal(PortalId).WithCulture(Language.Code, false);
                if (PortalSettings.ContentLocalizationEnabled && tabs.Count == 0)
                {
                    //Create Localized Pages
                    foreach (TabInfo t in tabCtrl.GetCultureTabList(PortalId))
                    {
                        tabCtrl.CreateLocalizedCopy(t, Language);
                    }

                    var portalCtl = new PortalController();
                    portalCtl.MapLocalizedSpecialPages(PortalId, Language.Code);
                }

                Response.Redirect(Globals.NavigateURL(), true);
                //Module failed to load
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        private void ProcessLanguage(List<TabInfo> pageList, Locale locale, int languageCount, int totalLanguages)
        {
            try
            {
                var tabCtrl = new TabController();
                RadProgressContext progress = RadProgressContext.Current;

                progress.Speed = "N/A";
                progress.PrimaryTotal = totalLanguages;
                progress.PrimaryValue = languageCount;

                int total = pageList.Count;
                for (int i = 0; i <= total - 1; i++)
                {
                    TabInfo currentTab = pageList[i];
                    int stepNo = i + 1;

                    progress.SecondaryTotal = total;
                    progress.SecondaryValue = stepNo;
                    float secondaryPercent = ((float)stepNo / (float)total) * 100;
                    progress.SecondaryPercent = Convert.ToInt32(secondaryPercent);
                    float primaryPercent = ((((float)languageCount + ((float)stepNo / (float)total)) / (float)totalLanguages)) * 100;
                    progress.PrimaryPercent = Convert.ToInt32(primaryPercent);

                    progress.CurrentOperationText = string.Format(Localization.GetString("ProcessingPage", LocalResourceFile), locale.Code, stepNo, total, currentTab.TabName);

                    if (!Response.IsClientConnected)
                    {
                        //clear cache
                        DataCache.ClearPortalCache(PortalId, true);

                        //Cancel button was clicked or the browser was closed, so stop processing
                        break;
                    }

                    progress.TimeEstimated = (total - stepNo) * 100;

                    tabCtrl.CreateLocalizedCopy(currentTab, locale, false);

                }
                var portalCtl = new PortalController();
                portalCtl.MapLocalizedSpecialPages(PortalId, locale.Code);

            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        protected void updateButton_Click(object sender, EventArgs e)
        {
            var tabCtrl = new TabController();
            var portalCtrl = new PortalController();
            int languageCount = LocaleController.Instance.GetLocales(PortalSettings.PortalId).Count;
            List<TabInfo> pageList = tabCtrl.GetDefaultCultureTabList(PortalId);

            int scriptTimeOut = Server.ScriptTimeout;
            Server.ScriptTimeout = timeout;

            int languageCounter = 0;
            if (chkAllPagesTranslatable.Checked)
            {
            ProcessLanguage(pageList, LocaleController.Instance.GetLocale(PortalDefault), languageCounter, languageCount);
            }
            PublishLanguage(PortalDefault, true);

            PortalController.UpdatePortalSetting(PortalId, "ContentLocalizationEnabled", "True");

            // populate other languages
            foreach (Locale locale in LocaleController.Instance.GetLocales(PortalSettings.PortalId).Values)
            {
                if (!IsDefaultLanguage(locale.Code))
                {
                    languageCounter += 1;
                    pageList = tabCtrl.GetCultureTabList(PortalId);

                    //add translator role
                    Localization.AddTranslatorRole(PortalId, locale);

                    //populate pages
                    ProcessLanguage(pageList, locale, languageCounter, languageCount);

                    //Map special pages
                    portalCtrl.MapLocalizedSpecialPages(PortalSettings.PortalId, locale.Code);
                }
            }
            //Restore Script Timeout
            Server.ScriptTimeout = scriptTimeOut;
            //clear portal cache
            DataCache.ClearPortalCache(PortalId,true);
            //'Redirect to refresh page (and skinobjects)
            Response.Redirect(Globals.NavigateURL(), true);
        }