Content by search web parts is new OTB way in Sharepoint 2013 to show content from search index. They have a lot of extensibility points, which make them useful in real-world applications (e.g. ability to use custom web templates or search results source). One problem which we found during working on search-driven site, is that by default they use client browser language for showing search results. I.e. we tested search results with the same search query rules, but with different browser languages (i.e. different Accept-Language http header), and results were different. Some time ago I already wrote about similar problem caused by using browser language for parsing dates in search queries (see Problem in KQL with date times and client object model in Sharepoint). It shows that search-related functionality in Sharepoint 2013 is heavily tight with client language because of some reason. And from my point of view this is controversial decision. At least in my practice in all cases it would be more safe and manageable to define on server side what language should be used for showing search results, instead of relying on client settings.
One example from real life: there is one web application with several language site collections. On production server language packs can’t be installed so all site collections are technically English site collections (SPWeb.Language is 1033 for all of them). In order to distinguish them by languages SPWeb.Locale is used (custom functionality uses it for retrieving strings from local resx files). In this case we need to use SPWeb.Locale set on server side for search results, but not client language. How to achieve it?
I analyzed code of Content by search web parts and related components and found that it uses one of the properties inside DataProviderJSON property called FallbackLanguage. By default it is set to –1:
This is the key for configuring Content by search web parts to not use client language: instead of –1 you should specify locale id, which you would like to use for search results by this Content by search web part. E.g. for Russian sites you should use 1049, for German – 1031, etc.
If you already have provisioned web parts on the living site you can modify them by the following PowerShell script:
It iterates through all sub sites in site collection, in each sub site it goes through all publishing pages and on each page it finds all Content by search web parts which have FallbackLanguage = -1 and changes them to specified locale id. After applying this script your Content by search web parts will use specified language for search results. Hope that it will help someone.