Refining by page language with PNP Search Web Parts

Meats Jessica 1 Reputation point
2021-08-31T11:21:59.36+00:00

I'm putting together a custom search page using the PNP search web parts. I have my search results working fine, but it's for a tenant that's using the SPO multilingual pages and I want to refine by the language of the page.

There is a property SPTranslatedLanguage, which shows the language of any page that's a translation, but shows null for a page in the default language. So if I have the default language on the site as English with French and German as an available translation languages, then the translated pages will be tagged as French or German in this property, but the original English page that they're translations of will be tagged null.

This means if I map SPTranslatedLanguage to a refinable string property and add this in the search filters web part, I can refine by French or German, but there will never be an English option to refine by. Does anyone know how I could create a refinable property that would let me filter by the default language as well?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,597 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor
    2021-09-01T08:40:37.073+00:00

    Hi @Meats Jessica ,
    We can refer to the following link to add refiners to your search results
    https://learn.microsoft.com/en-us/sharepoint/search/how-to-add-refiners-to-your-search-results-page


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Martin Laplante 316 Reputation points
    2021-09-01T11:49:47.043+00:00

    You can search on SPIsTranslation to return source pages on sites where Multilingual Page Publishing feature is on. That assumes that this source language is always English. If the source is not always English, then you can check for the combination of SPIsTranslation and SPTranslatedLanguages not including English.

    If you want to find things by language regardless of whether the feature is on, then you can search by the managed property DetectedLanguage.

    0 comments No comments

  3. Meats Jessica 1 Reputation point
    2021-09-01T13:31:57.237+00:00

    @Martin Laplante
    When I pull back SPIsTranslation, the debug mode on the search webpart is showing that property set to False for every result - even the ones that have a translated language. Even if I could retrieve this property correctly, it wouldn't be ideal because then I would have one refiner for "is it translated" as a yes or no and then another refiner for the translated language, instead of a single refiner for language.

    I can't see DetectedLanguage as one of the optional properties to retrieve in the search results settings and when I try to map this onto a refinable string property, it doesn't show up in the search of crawled properties available to apply to a mapping. Am I missing something here?


  4. Meats Jessica 1 Reputation point
    2021-09-02T12:54:39.25+00:00

    DetectedLanguage is a managed property but it's not a refinable one, and I can't see it on the list of properties to retrieve in the search result web part.