示例#1
0
        /// <summary>
        /// Languaje function to activate some of which we have installed
        /// </summary>
        /// <param name="web">Sitio Web donde lo queremos desplegar </param>
        /// <param name="lcidLanguage">LCID of language we want to activate</param>
        /// <returns></returns>
        public static bool EnableSiteCollectionLanguage(this SPWeb web, int lcidLanguage)
        {
            var result = true;

            try
            {
                if (web.Site.GetWebTemplates(web.Language)[web.WebTemplate].SupportsMultilingualUI)
                {
                    web.IsMultilingual = true;

                    var installed = SPLanguageSettings.GetGlobalInstalledLanguages(15);
                    var supported = web.SupportedUICultures;
                    foreach (SPLanguage language in installed)
                    {
                        var culture = new CultureInfo(language.LCID);
                        if (!supported.Contains(culture) && language.LCID == lcidLanguage)
                        {
                            web.AddSupportedUICulture(culture);
                        }
                    }
                    web.Update();
                }
            }
            catch (Exception exception)
            {
                Logger.Error("Error EnableSiteCollectionLanguage", exception.Message);
                result = false;
            }
            return(result);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Gets the list of installed languages and bind them to DropDownList control.
                SPLanguageCollection languages = SPLanguageSettings.GetGlobalInstalledLanguages(15);
                ddlLanguages.DataSource = languages;
                ddlLanguages.DataBind();

                // Add a item at the top of the DropDownList and and set it selected by default.
                ddlLanguages.Items.Insert(0, "NotSelected");
                ddlLanguages.SelectedIndex = 0;
            }
        }
示例#3
0
        public static void ActiveInstalledLanguage(SPWeb newSite)
        {
            // Enable MUI.
            newSite.IsMultilingual = true;

            // Add support for any installed language currently not supported.
            SPLanguageCollection      installed = SPLanguageSettings.GetGlobalInstalledLanguages(15);
            IEnumerable <CultureInfo> supported = newSite.SupportedUICultures;

            foreach (SPLanguage language in installed)
            {
                CultureInfo culture = new CultureInfo(language.LCID);

                if (!supported.Contains(culture))
                {
                    newSite.AddSupportedUICulture(culture);
                }
            }
            newSite.AllowUnsafeUpdates = true;
            newSite.Update();
        }