Copied to clipboard

Flag this post as spam?

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


  • Martijn 3 posts 73 karma points
    Sep 17, 2020 @ 10:01
    Martijn
    0

    How to return only pages that matches the specified culture using the ContentQuery?

    My setup is multilingual. I have setup en-Us and nl. nl does not have a fallback language.

    In my tree structure in Umbraco I have page and for this page I have content for two languages: en-US and nl. Both off course have content in their own language.

    For en-us content I have used the content: 'acracadabra' and for nl I have entered 'Nederland'. Just that, nothing more.

    Now, when I want to search for content using code, I get the english content back when I search for dutch content. This is not what I want.

    So, when using this code:

    // UmbracoHelper is injected in my constructor and stored in _umbracoHelper.
    var searchResults = _umbracoHelper.ContentQuery.Search("Nederland", "en-Us");
    

    So, I am searching for 'Nederland' using the en-US culture. I would expect no results, but I do! I get the English version back with the content 'acracadabra'. I know this a translation of the 'same' page, but when I look for en-US content I would expect only to get english content back, not content from another language!

    I have also tried to set _variationContextAccessor.VariationContext but without succes.

    So, my question is, what do I need to do so I get only those pages using the specified culture. Using the example above, I would expect no results when searching for 'Nederland' in the en-us culture.

Please Sign in or register to post replies

Write your reply to:

Draft