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;
            }
            _orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName;

            Context.Output.WriteLine(T("Site culture set to {0} successfully", cultureName));
        }
Example #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;
            }
        }
Example #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;
            });
        }
Example #4
0
        public void RemoveSiteCulture(string cultureName)
        {
            Context.Output.WriteLine(T("Removing site culture {0}", cultureName));

            if (!_cultureManager.IsValidCulture(cultureName))
            {
                Context.Output.WriteLine(T("Supplied culture name {0} is not valid.", cultureName));
                return;
            }
            if (_orchardServices.WorkContext.CurrentSite.SiteCulture == cultureName)
            {
                Context.Output.WriteLine(T("Cannot remove current culture {0} from site. Change current culture first.", cultureName));
                return;
            }

            var cultureCheck = _cultureManager.ListCultures().FirstOrDefault(x => x == cultureName);

            if (string.IsNullOrEmpty(cultureCheck))
            {
                Context.Output.WriteLine(T("Culture {0} is not activated on this site.", cultureName));
                return;
            }
            _cultureManager.DeleteCulture(cultureName);

            Context.Output.WriteLine(T("Site culture {0} removed successfully", cultureName));
        }
Example #5
0
 public bool IsValidCulture(string cultureName)
 {
     return(_underlyingCultureManager.IsValidCulture(cultureName));
 }