public void SetSiteCulture(string cultureName)
        {
            Context.Output.WriteLine(T("Setting site culture to {0}", cultureName));

            if (!_cultureManager.IsValidCulture(cultureName))
            {
                Context.Output.WriteLine(T("Supplied culture name {0} is not valid.", cultureName));
                return;
            }

            _cultureManager.AddCulture(cultureName);
            _coeveryServices.WorkContext.CurrentSite.SiteCulture = cultureName;

            Context.Output.WriteLine(T("Site culture set to {0} successfully", cultureName));
        }
Esempio n. 2
0
        protected override void Importing(LocalizationPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var masterContentItem = context.Attribute(part.PartDefinition.Name, "MasterContentItem");

            if (masterContentItem != null)
            {
                var contentItem = context.GetItemFromSession(masterContentItem);
                if (contentItem != null)
                {
                    part.MasterContentItem = contentItem;
                }
            }

            var culture = context.Attribute(part.PartDefinition.Name, "Culture");

            if (culture != null)
            {
                var targetCulture = _cultureManager.GetCultureByName(culture);
                // Add Culture.
                if (targetCulture == null && _cultureManager.IsValidCulture(culture))
                {
                    _cultureManager.AddCulture(culture);
                    targetCulture = _cultureManager.GetCultureByName(culture);
                }
                part.Culture = targetCulture;
            }
        }
Esempio n. 3
0
        protected override void Importing(LocalizationPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "MasterContentItem", masterContentItem => {
                var contentItem = context.GetItemFromSession(masterContentItem);
                if (contentItem != null)
                {
                    part.MasterContentItem = contentItem;
                }
            });

            context.ImportAttribute(part.PartDefinition.Name, "Culture", culture => {
                var targetCulture = _cultureManager.GetCultureByName(culture);
                // Add Culture.
                if (targetCulture == null && _cultureManager.IsValidCulture(culture))
                {
                    _cultureManager.AddCulture(culture);
                    targetCulture = _cultureManager.GetCultureByName(culture);
                }
                part.Culture = targetCulture;
            });
        }
Esempio n. 4
0
        protected override void Importing(SiteSettingsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            var supportedCultures = context.Attribute(part.PartDefinition.Name, "SupportedCultures");

            if (supportedCultures != null)
            {
                foreach (var culture in supportedCultures.Split(';'))
                {
                    _cultureManager.AddCulture(culture);
                }
            }
        }
Esempio n. 5
0
        public void CultureManagerCanAddAndListValidCultures()
        {
            _cultureManager.AddCulture("tr-TR");
            _cultureManager.AddCulture("fr-FR");
            _cultureManager.AddCulture("bs-Latn-BA");
            List <string> cultures = new List <string>(_cultureManager.ListCultures());

            Assert.That(cultures.Count, Is.Not.EqualTo(0));
        }
Esempio n. 6
0
        public ActionResult AddCulture(string systemCultureName, string cultureName)
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage settings")))
            {
                return(new HttpUnauthorizedResult());
            }

            cultureName = string.IsNullOrWhiteSpace(cultureName) ? systemCultureName : cultureName;

            if (!string.IsNullOrWhiteSpace(cultureName))
            {
                _cultureManager.AddCulture(cultureName);
            }
            return(RedirectToAction("Culture"));
        }
Esempio n. 7
0
        public ActionResult AddCulture(string systemCultureName, string cultureName)
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageSettings, T("无权限")))
            {
                return(new HttpUnauthorizedResult());
            }

            cultureName = string.IsNullOrWhiteSpace(cultureName) ? systemCultureName : cultureName;

            if (!string.IsNullOrWhiteSpace(cultureName))
            {
                _cultureManager.AddCulture(cultureName);
            }
            return(RedirectToAction("Culture"));
        }
        protected override void Importing(SiteSettingsPart part, ContentManagement.Handlers.ImportContentContext context)
        {
            // Don't do anything if the tag is not specified.
            if (context.Data.Element(part.PartDefinition.Name) == null)
            {
                return;
            }

            context.ImportAttribute(part.PartDefinition.Name, "SupportedCultures", supportedCultures => {
                foreach (var culture in supportedCultures.Split(';'))
                {
                    _cultureManager.AddCulture(culture);
                }
            });
        }
Esempio n. 9
0
        public void AddCultures(params string[] cultureNames)
        {
            IEnumerable <string> siteCultures = _cultureManager.ListCultures();

            Context.Output.WriteLine(T("Adding site cultures {0}", string.Join(",", cultureNames)));

            foreach (var cultureName in cultureNames.Distinct().Where(s => !siteCultures.Contains(s)))
            {
                if (_cultureManager.IsValidCulture(cultureName))
                {
                    _cultureManager.AddCulture(cultureName);
                }
                else
                {
                    Context.Output.WriteLine(T("Supplied culture name {0} is not valid.", cultureName));
                }
            }
        }
Esempio n. 10
0
 public void AddCulture(string cultureName)
 {
     _underlyingCultureManager.AddCulture(cultureName);
 }