Exemplo n.º 1
0
        public ActionResult Enabled(int lid)
        {
            string       ResourcesFile = "~/DesktopModules/Vanjaro/UXManager/Extensions/Menu/" + ExtensionInfo.Name + "/Views/Setting/App_LocalResources/Languages.resx";
            ActionResult actionResult  = new ActionResult();
            Locale       language      = LocaleController.Instance.GetLocale(lid);

            if (language == null)
            {
                actionResult.AddError("InvalidLocale.ErrorMessage", string.Format(Localization.GetString("InvalidLocale.ErrorMessage", ResourcesFile), language.Code));
                return(actionResult);
            }
            if (PortalSettings.DefaultLanguage != language.Code)
            {
                if (LanguagesManager.IsLanguageEnabled(PortalSettings.PortalId, language.Code))
                {
                    //remove language from portal
                    Localization.RemoveLanguageFromPortal(PortalSettings.PortalId, language.LanguageId);
                    LanguagesManager.SetTabUrlsActiveToRedirect(language.LanguageId);
                }
                else
                {
                    //Add language to portal
                    Localization.AddLanguageToPortal(PortalSettings.PortalId, language.LanguageId, true);
                    LanguagesManager.UpdateTabUrlsDefaultLocale();
                }
            }
            actionResult.Data      = LanguagesManager.GetLanguages(PortalSettings, UserInfo);
            actionResult.IsSuccess = true;
            return(actionResult);
        }