Copied to clipboard

Flag this post as spam?

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


  • David Gregory 85 posts 211 karma points
    Mar 19, 2019 @ 15:03
    David Gregory
    0

    GetDictionaryValue by passing in Culture

    Hi

    I have a bilingual site with lots of Dictionary items that Umbraco nicely takes care of using Umbraco.GetDictionaryValue("MyValueName")

    However, I have a piece of content that's only available in one language (English) and therefore it only lives in the English content tree.

    Problem is, in my view, I still want to call Umbraco.GetDictionaryValue() but as my currentpage will always be English, I only get the English value returned.

    I suppose my question is, can I force the culture when I make the call? Something like Umbraco.GetDictionaryValue("MyValueName", myLang)

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 19, 2019 @ 15:10
    Alex Skrypnyk
    101

    Hi David

    You can set current request culture with this code:

    System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("needed culture");
    

    And After that, GetDictionaryValue will return that value.

    Thanks,

    Alex

  • David Gregory 85 posts 211 karma points
    Mar 19, 2019 @ 15:58
    David Gregory
    0

    Perfect, thanks.

Please Sign in or register to post replies

Write your reply to:

Draft