Copied to clipboard

Flag this post as spam?

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


  • Herman 20 posts 141 karma points
    Apr 25, 2014 @ 13:45
    Herman
    0

    Wrong language when loading data dynamically

    Hi, I have a multilanguage site that uses Umbracos dictionary feature to translate words. My problem is when im loading partialviews with jQuery load the dictionary items is on English and not the language the root node is set to. This only happens when the data is loaded after the view is loaded. All other dictionary items on my page works fine.

    This is how i get the dictionary value from the partialview:

    @Umbraco.GetDictionaryValue("Send")
    

    Can i set the culture from the controller somehow?

    Thanks in advance!

  • Herman 20 posts 141 karma points
    Oct 30, 2014 @ 13:23
    Herman
    101

    I found a solution, pass the culture to the surface controller then set the culture and it will work:

    public class CartController : SurfaceController
    {
            public ActionResult AddToCart(int id,int amount, string culture)
                // Dictionary fix - Set culture
                System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
    
                return PartialView("AddToCart");   
            }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft