Copied to clipboard

Flag this post as spam?

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


  • Rickard Liljeberg 23 posts 114 karma points
    Feb 26, 2016 @ 16:29
    Rickard Liljeberg
    0

    Translations in custom sections

    I am developing a custom section, my section has a TreeController.

    I add nodes to it like this:

                nodes.Add(CreateTreeNode(
                    "-10",
                    "-1",
                    queryStrings,
                    Umbraco.GetDictionaryValue("Events"),
                    "icon-slideshow",
                    false));
    

    Now my user has language set to Swedish and I have added Swedish language and added dictionary with "Events" as well as many other things in my dictionary.

    Now here is the thing, I could have sworn that this worked like it was supposed last time, but today when I pick up where I left off I get a blank string back from this method: Umbraco.GetDictionaryValue("Events")

    If I debug and check my culture or UI culture they are set to "en-GB" even tho I have Swedish set for my user (the rest of umbraco interface is in Swedish).

    However, If I do these two lines of code

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

    It all works, but then of course I have forced Swedish. I want people to get the language they have set their user to.

    Any clues? Is it supposed to set culture to users selected language? If not, how can I get it to translate it to the users language?

  • Rickard Liljeberg 23 posts 114 karma points
    Feb 26, 2016 @ 16:45
    Rickard Liljeberg
    0

    So, of course after posting I figured it out, mostly.

    The culture is indeed set to the users language. However it takes loggin out and back in to take effect.

    One bug or another led my user to having en-GB even tho language selected was Swedish the whole time.

    So what I did was change to danish, log out, log in... end behold the culture was danish.

    I then set it back to Swedish, logged out, logged in and it was correct again and showed the translations.

Please Sign in or register to post replies

Write your reply to:

Draft