1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / "localizing" News Items

"localizing" News Items

2 posts, 0 answered
  1. HRC
    HRC avatar
    44 posts
    Registered:
    16 Mar 2009
    24 Mar 2010
    Link to this post
    Hello, here's my situation.

    I need to programatically insert a news item into the CMS, and also localize that item for all languages available through the  CMS (7 of them). All the content should remain identical.

    All should end up in DRAFT state

    I'm at the point where my default language entry is inserted correctly, however, every alternate language item is automatically "locked by admin"  and while the MetaData elements like the title show up correctly in the news list (in the SF admin interface) they appear blank once the item is edited.

         
        protected void finalNewsSubmit(object sender, EventArgs e)
        {
    ContentManager contentManager = new ContentManager("News");
       Telerik.News.NewsManager newsManager = new Telerik.News.NewsManager("News");
                          
       Telerik.Cms.Engine.IContent newsContent = newsManager.Content.CreateContent("text/html");
      
                   // save the Content property value, and the Title meta key
                    newsContent.SetMetaData("Category", "Wall Profiles");
                    newsContent.SetMetaData("Title", "Wall Submission - " + txt_name.Text);
                    newsContent.SetMetaData("Author", txt_name.Text);
                    newsContent.Content = txt_message.Text;
      
      
                    newsManager.Content.SaveContent(newsContent, ContentStatus.Published);
      
      
                    foreach (KeyValuePair<String,System.Globalization.CultureInfo > x in Telerik.Localization.LocalizationManager.Cultures)
                    {
                        if (x.Key != "en")
                        {
                          //  newsContent.Languages.Add(x.Key);
                            IContent altLangContent = contentManager.GetStagedContent(newsContent.ID);
                                  
                            altLangContent.Language = x.Key;
                            altLangContent.SetMetaData("Category", "Wall Profiles");
                            altLangContent.SetMetaData("Title", "Wall Submission - " + txt_name.Text);       altLangContent.SetMetaData("Author", txt_name.Text);
      
                            altLangContent.Content = txt_message.Text;
                            contentManager.SaveContent(altLangContent,ContentStatus.Published);
                        }
                    }
      
      
                    
                    clearFieldsAndSession();
    }

    Any insight on what i should be doing?

    thanks

    -Kris
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Mar 2010
    Link to this post
    Hi HRC,

    Thank you for using our services.

    We have sent a response to the support ticket you have opened with the same issue. Here is our response from there:
    You are on the right track, however you need to make some changes to your code. Instead of setting the language property try changing the default UI culture and then getting the staged content. Sample bellow:
    Copy Code
    protected void finalNewsSubmit(object sender, EventArgs e)
    {
        ContentManager contentManager = new ContentManager("News");
        Telerik.News.NewsManager newsManager = new Telerik.News.NewsManager("News");
        Telerik.Cms.Engine.IContent newsContent = newsManager.Content.CreateContent("text/html");
        // save the Content property value, and the Title meta key
        newsContent.SetMetaData("Category", "Wall Profiles");
        newsContent.SetMetaData("Title", "Wall Submission - " + txt_name.Text);
        newsContent.SetMetaData("Author", txt_name.Text);
        newsContent.Content = txt_message.Text;
        newsManager.Content.SaveContent(newsContent, ContentStatus.Published);
        CultureInfo currentUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
        foreach (KeyValuePair<String, System.Globalization.CultureInfo> x in Telerik.Localization.LocalizationManager.Cultures)
        {
            if (x.Value != currentUICulture)
            {
                //  newsContent.Languages.Add(x.Key);
                System.Threading.Thread.CurrentThread.CurrentUICulture = x.Value;
                IContent altLangContent = contentManager.GetStagedContent(newsContent.ID);
     
                altLangContent.SetMetaData("Category", "Wall Profiles");
                altLangContent.SetMetaData("Title", "Wall Submission - " + txt_name.Text); altLangContent.SetMetaData("Author", txt_name.Text);
     
                altLangContent.Content = txt_message.Text;
                contentManager.SaveContent(altLangContent, ContentStatus.Published);
            }
        }
        System.Threading.Thread.CurrentThread.CurrentUICulture = currentUICulture;
        clearFieldsAndSession();
    }

    If you wish to create them with status draft you should save them with this status rather than with published.


    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered