Copied to clipboard

Flag this post as spam?

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


  • Zoran Latinovic 6 posts 86 karma points
    Aug 16, 2020 @ 10:48
    Zoran Latinovic
    0

    Getting current published language/culture variant in ContentService events

    Hi,

    I have multi lingual site and it is implemented using language variants.

    Is there a way to get which language variant or Culture is published in ContentService events?

    ContentService events are implemented in custom component and when I'm trying to get culture using Thread.CurrentThread.CurrentCulture.Name it always gets 'en-Us'.

    IContent in event only has properties with all cultures.

    Is there a way to get this language variant when in ContentService events? https://prnt.sc/u0ewfy

  • Yakov Lebski 427 posts 1654 karma points
    Aug 17, 2020 @ 02:57
    Yakov Lebski
    100

    Did you mean in saved and Published Events? you can use PublishedCultures

      public void Initialize()
            {  
                ContentService.Saved += ContentService_Saved;
            }
    
            private void ContentService_Saved(IContentService sender, ContentSavedEventArgs e)
            {           
    
                foreach (var content in e.SavedEntities)
                {
                    foreach (var culture in content.PublishedCultures)
                    {
    
    
                        }
    
                    }
    
                }
            }
    
  • 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