Copied to clipboard

Flag this post as spam?

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


  • Josip 152 posts 594 karma points c-trib
    Sep 11, 2019 @ 20:07
    Josip
    0

    How to change culture for Umbraco helper in controller

    Hi All,

    I have 2 languages (English and German) and I want to query English nodes in my SurfaceController but I am getting German nodes.

    node.Name("en-US") is not solution, because i am using this code for autocomplete in my search.

    This is my code:

    var data = "en-US";
    CultureInfo culture = CultureInfo.CreateSpecificCulture(data);
    
                Thread.CurrentThread.CurrentCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;
                List<string> companys = new List<string>();
                if (type == "categories")
                {
                    ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index);
                    var searcher = index.GetSearcher();
                    var results = searcher.CreateQuery("content").NodeTypeAlias("category").And().Field("nodeName", search.MultipleCharacterWildcard()).Execute();
                    if (results.Any())
                    {
                        foreach (var result in results)
                        {
                            if (result.Id != null)
                            {
                                var node = Umbraco.Content(result.Id);
                                companys.Add(node.Name);
                            }
                        }
                    }
                    return new JsonResult { Data = companys, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                }
    
  • Shaishav Karnani from digitallymedia.com 330 posts 1562 karma points
    Sep 12, 2019 @ 05:30
    Shaishav Karnani from digitallymedia.com
    0

    Hi Josip,

    Have you selected your default language as German that could be resulting to default German when you tried node.Name.

    Please have a look and confirm.

    Cheers,

    Shaishav

  • Josip 152 posts 594 karma points c-trib
    Sep 12, 2019 @ 11:15
    Josip
    0

    Hi Shaishav,

    This are the language settings in Umbraco backoffice: enter image description here

    I need something like this var node = Umbraco.Content(result.Id, "en-US"); I know it is not possible to it that way but you get the idea.

    BR

    Josip

  • Josip 152 posts 594 karma points c-trib
    Sep 20, 2019 @ 20:02
    Josip
    0

    Any ideas?

  • Josip 152 posts 594 karma points c-trib
    Sep 23, 2019 @ 10:37
    Josip
    100

    Finaly found the solution in this post:

    @Dave de Moel answer

Please Sign in or register to post replies

Write your reply to:

Draft