Copied to clipboard

Flag this post as spam?

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


  • Jan van Helvoort 15 posts 71 karma points
    Apr 16, 2014 @ 17:44
    Jan van Helvoort
    0

    UmbracoApiController wrong language

    Hi,

    How do I set the language of the dictionaryhelper? The whole site is Dutch.

    With the Views, RenderMvcController and SurfaceController the method: DictionaryHelper.Translate gave the Dutch item from the dictionary.

    If I use the same method on a UmbracoApiController, The English item from the dictionary is returned.

    Why?

    Greets Jan

  • Jamie Pollock 174 posts 853 karma points c-trib
    Apr 16, 2014 @ 18:22
    Jamie Pollock
    0

    Hi Jan,

    Have you set the culture of the website to be Dutch?

    You can do this by right-clicking on your website root (the top level node not the "Content" node) and selecting the "Culture and Hostnames" option.

    From there you select the culture "nl-nl" should be one of the options.

    Thanks,
    Jamie

  • Jan van Helvoort 15 posts 71 karma points
    Apr 16, 2014 @ 18:35
    Jan van Helvoort
    0

    Yes, Therefore I find it so strange the api is english.

  • Michael Lake 2 posts 72 karma points
    Sep 11, 2017 @ 22:24
    Michael Lake
    0

    Hi Jan,

    did you find the solution to this issue? Would be great to know how you solved it.

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Sep 12, 2017 @ 08:17
    Ismail Mayat
    0

    Guys,

    Not sure if relevant but I recall with Umbraco v6 surfacecontrollers when making ajax calls the language context was being lost so i had to do the following:

            protected void SetCultureForAjax()
        {
            //we lose culture and dictionary wont get labels therefore set it on the thread
            string code = _umbracoService.GetCultureCode();
            //Get the culture info of the language code
            CultureInfo culture = CultureInfo.CreateSpecificCulture(code);
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
    

    The GetCultureCode is getting the culture set on current node. So you could maybe do something similar?

  • Michael Lake 2 posts 72 karma points
    Sep 12, 2017 @ 08:31
    Michael Lake
    0

    Thanks for this - I will give it a try.

    For the moment though I am lucky enough to only want 1 timezone - so I currently do this to get the local time:

    var tz = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
    return TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, tz);
    
Please Sign in or register to post replies

Write your reply to:

Draft