Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel B 7 posts 77 karma points
    May 29, 2020 @ 00:42
    Daniel B
    0

    Get culture from current node

    Hi All;

    I subscribe to the ContentService.Publishing in a Component and trying to get culture from current node to make validations based on language

    I try with node.AvailableCultures , but something is missing

    Is there a way to get the culture?

        private void ContentService_Publishing(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishingEventArgs e)
        {
    
            foreach (var node in e.PublishedEntities)
            {
    

    Thanks in advance

  • Joep 96 posts 698 karma points
    May 29, 2020 @ 09:25
    Joep
    1

    Hi,

    I think you can just use the IsPublishingCulture extension to check the culture? I am not too sure since I have never used it myself.

     private void ContentService_Publishing(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishingEventArgs e)
        {
    
        foreach (var node in e.PublishedEntities)
        {
               if(e.IsPublishingCulture(node, "en-GB"){}
    

    Let me know how it goes!

    -Joep

  • Daniel B 7 posts 77 karma points
    May 29, 2020 @ 18:31
    Daniel B
    0

    Hi Joep,

    Thanks a lot, I try IsPublishingCulture extension and It worked like a charm!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies