Copied to clipboard

Flag this post as spam?

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


  • Edgar Rasquin 326 posts 925 karma points
    Dec 02, 2022 @ 13:49
    Edgar Rasquin
    0

    contentservice saveandpublish additional culture

    Hi,

    I have a node published in the default culture ("de").

    How can I publish this node in an additional culture ("it")?

    My aproach is, to first get the node using its id:

    var course = contentService.GetById(courseId);
    

    I than set a value in the additional culture:

    course.SetValue("headline", name, "it");
    

    Finally I save & publish setting the additional culture:

    contentService.SaveAndPublish(course, "it");
    

    In the backend the node is still greyed out.

    Can anyone help?

    Thanks

  • David Peck 687 posts 1863 karma points c-trib
    Dec 02, 2022 @ 14:05
    David Peck
    0

    Probably a stupid question; is 'it' enabled as a culture in the settings section?

  • Edgar Rasquin 326 posts 925 karma points
    Dec 02, 2022 @ 14:24
    Edgar Rasquin
    0

    Hi David,

    thanks for your reply.

    I have these language settings: enter image description here

    Regards

  • David Peck 687 posts 1863 karma points c-trib
    Dec 02, 2022 @ 14:25
    David Peck
    0

    I thought it would be a stupid question, but it's always worth checking the basics.

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Dec 02, 2022 @ 14:35
    Kevin Jump
    101

    Hi,

    you might also need to set the culture name for the node

    e.g

    course.SetCultureName(name, "it");
    
  • Edgar Rasquin 326 posts 925 karma points
    Dec 02, 2022 @ 15:13
    Edgar Rasquin
    0

    Hi Kevin,

    that did the trick!

    I had already tried that but it didn't work because I had only created the node in the "it" culture. When I tried to save the node manually in the backend, I got the message that it has to be in the default language first. After I created a node in "de" and then used your code, it worked perfectly!

    Many thanks for your help!

  • David Peck 687 posts 1863 karma points c-trib
    Dec 02, 2022 @ 14:37
    David Peck
    0

    Next stupid question but is the course's DocType set to vary by culture along with the headline property?

    Also try this:

    course.PublishCulture(new CultureImpact() { Culture = "it" });
    

    Reading the IContent API docs, it looks like you might need to call this for the culture to exists.

  • David Peck 687 posts 1863 karma points c-trib
    Dec 02, 2022 @ 14:38
    David Peck
    0

    I'm looking at Umbraco 10. Always go with what Kevin says.

  • Edgar Rasquin 326 posts 925 karma points
    Dec 02, 2022 @ 15:15
    Edgar Rasquin
    0

    Many thanks David.

    I will keep that in mind for when I move on to Umbraco 10!

    Thanks for your help. Have a nice day.

Please Sign in or register to post replies

Write your reply to:

Draft