I have different searchIndexes for the different languages so I need to know which index to ReIndex. The code that I have so far is:
public void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
foreach (var content in e.PublishedEntities)
{
if (content.ContentType.Alias == "node")
{
foreach (var child in content.Descendants().Where(c => c.ContentType.Alias == "subNode"))
{
ExamineManager.Instance.IndexProviderCollection[GetIndexer(culture)].ReIndexNode(child.ToXml(applicationContext.Services.PackagingService), "content");
}
}
The method GetIndexer() check the culture and returns the respective value.
The problem is that var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; is always "en-US" which is (I guess) the culture of the logged in in Umbraco user.
Is there a way to get the culture of the item that I am publishing?
Isn't there any way to get the culture from the IContent object instead? I mean, when publishing you can only publish one culture so shouldn't the IContent object contain this information? (Asking because I haven't managed to find it yet :) )
Get Culture from IContent in ContentService_Published method
Hi, I have a multilingual website and I use ContentService_Published method to do some custom logic when I publish a node - I need to do
I have different searchIndexes for the different languages so I need to know which index to ReIndex. The code that I have so far is:
The method GetIndexer() check the culture and returns the respective value. The problem is that var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; is always "en-US" which is (I guess) the culture of the logged in in Umbraco user. Is there a way to get the culture of the item that I am publishing?
Mila
You could get the node from cache & get the culture from there.
Isn't there any way to get the culture from the IContent object instead? I mean, when publishing you can only publish one culture so shouldn't the IContent object contain this information? (Asking because I haven't managed to find it yet :) )
Hi, Searching for the same thing..... any luck? thanks. Rihab.
Searching for the same thing.. :D Anybody?
An old thread but the answer is that culture info can be found in IContent under
.PublishCultureInfos
is working on a reply...