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
    May 14, 2018 @ 12:53
    Edgar Rasquin
    0

    set culture using contentSevice

    Hi everyone,

    does somebody know whether it's possible to set the culture using the contentService?

    Currently I am doing something like this:

    // create content service
            var contentService = ApplicationContext.Current.Services.ContentService;
    
            //create unique name for umbraco
            var uniqueName = name + code;
    
            var newJobPost = contentService.CreateContentWithIdentity(uniqueName, 4483, "job");
    
            newJobPost.SetValue("betreff", name);
            newJobPost.SetValue("code", code);
            newJobPost.SetValue("location", location);
            ...            
    
            //save & publish
            var status = contentService.SaveAndPublishWithStatus(newJobPost);
    

    That creates nodes with the the culture "inherit".

    Is there a way I can set a specific culture like "de" or "it"... ?

    Thanks a lot.

    enter image description here

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 01, 2018 @ 09:59
    Alex Skrypnyk
    100

    Hi Edgar

    You need to set culture to thread like that:

    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookieLingua);
    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookieLingua);
    

    Alex

  • Edgar Rasquin 326 posts 925 karma points
    Aug 01, 2018 @ 10:02
    Edgar Rasquin
    0

    Hi Alex,

    thank you very much for your help. Very much appreciated!

    Regards

  • Rivkiker 6 posts 27 karma points
    May 23, 2023 @ 08:08
    Rivkiker
    0

    Can I update the culture of existing node?

Please Sign in or register to post replies

Write your reply to:

Draft