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 };
}
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:
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
Hi Shaishav,
This are the language settings in Umbraco backoffice:
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
Any ideas?
Finaly found the solution in this post:
@Dave de Moel answer
is working on a reply...