Access localization value for a contentItem

Topics: Localization
Mar 26, 2012 at 4:30 PM

I'am trying to create a different culture version for some contentItem , the contentItems are contained in a list , and i want to test if the currentCulture match the contentItem culture to display it or not .

for example

 

@foreach (dynamic item in items)
{

  if ( currentCulture == item.ContentItem.Culture ){
     var html = new HtmlString(item.ContentItem.BodyPart.Text);
      @html
    }   
}

 

this what i want to accomplish .

 

I dont know if this the right way to do it ? Let me know if you have suggestion.

Mar 29, 2012 at 2:43 AM

I don't understand why nobody answer me or help me !! So it took me two days digging in the source code and looking at some localisation module to figure it out. But can someone please clarify what we need to do to have some answers in this forum ??? Do we need to have some special status to get answers ??? or is this question not important or is it something obvious ?? ....

 

So for some people may want to use the same solution here what i used .

I used this in order to have a list of items in a widget the list contains items in different culture so when the page culture is changed the list is filtered .

So i thought that this might be useful

@using Orchard;
@using Orchard.Localization.Services;
@{
    IEnumerable<object> items = Model.ContentItems;
    Model.Metadata.Wrappers.Clear();
  
}
@foreach (dynamic item in items)
{
    
    if (WorkContext.CurrentCulture == item.ContentItem.LocalizationPart.Culture.Culture)
    {
        var html = new HtmlString(item.ContentItem.BodyPart.Text);
        @html
    }
    
}</object>

Mar 29, 2012 at 5:19 AM

Sometimes a question may get overlooked or no one who knows the answer has had a chance to respond yet. After reading your OP I had no idea what your question was, so that might have played a part as well.