Copied to clipboard

Flag this post as spam?

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


  • K.Garrein 164 posts 629 karma points
    Dec 14, 2020 @ 11:10
    K.Garrein
    0

    Grid Html varying by culture???

    Hey all.

    Getting model content by culture seems pretty straightforward:

    Model.Value( "intro", culture: "en-GB" )
    

    But how do I get GridHtml by culture??? There doesn't seem to be a parameter for this in the Html.GetGridHtml method?

    Any suggestions?

  • Dhanesh Kumar MJ 159 posts 513 karma points MVP c-trib
    Dec 14, 2020 @ 14:05
    Dhanesh Kumar MJ
    100

    Hi Garrien,

    Yes, there is no param for culture in GridHtml. The culture will automatically pick from the Current Thread / Node culture.

    But we can switch the culture using the following code

     var lang="da" //culture iso code you can change here
     var data = UmbracoContext.VariationContextAccessor.VariationContext = new VariationContext(lang);
            Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
    

    This will change the current culture and then you just call the GridHtml method, then the data will show against the culture you set :).

    Regards Dhanesh :)

  • K.Garrein 164 posts 629 karma points
    Dec 14, 2020 @ 14:28
    K.Garrein
    0

    Thank you. It works with your advise!

    Kind regards. Kris.

Please Sign in or register to post replies

Write your reply to:

Draft