Localization of Managed Properties Titles in Refinement Panels for SharePoint 2013
The new refinement panel for SharePoint 2013 search is build completely different from its predecessor in 2010, and follows the new pattern of showing data using display templates. This makes it really easy to customize and can be done by anyone with html/js/css knowledge, without any previously required xsl knowledge.
The default display templates for refinement panels (Filter_Default.js, Filter_MultiValue.js) use a method for retrieving the title of a search managed property.
Srch.Refinement.getRefinementTitle(ctx.RefinementControl);
This goes through the following steps to find the title for the refinement:
- It looks in currently loaded js resource files. If the managed property key is found, the result is returned. I have described here how to use js resource files for display templates in SharePoint 2013.
- It looks in the Search default resource files – these can be found in {15}/Resources with the name pattern Srch.resources.{culture}.resx
- if nothing is found, returns the name of the managed property
The managed property key it looks for is in the format “rf_RefinementTitle_{ManagedProperty}”. Therefore, if the managed property it currently displays is “LastModifiedTime” it will look for a resource with key “rf_RefinementTitle_LastModifiedTime”.
Considering these steps, you can localize new managed properties in your search center, but you can also change the titles for the existing ones. You can use the default “CustomStrings.js” resource file for the new managed properties titles, or you can create your own js resource file, but you must make sure that the file is loaded in the page. Some display templates automatically load the default resource file, but otherwise you can add a Content Editor web part to the page to load your resource file.
$includeLanguageScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Language Files/MyCustomResourceFile.js");
Great post.
Do you know its possible to localize the values as well or is it just the titles?
I am able to override the values of standard refiners using this syntax:
“rf_ResultTypeRefinerValue_Webpage”: “My web page”
For my own refiner called Country I try this, but it does not work:
“rf_CountryRefinerValue_Norway”: “Norge”
Are there any other way to do this?
Hi Tommy,
You could create your own display template, starting from the default refiner display template (filter_default.js) and support this localization of values. “rf_ResultTypeRefinerValue_Webpage” this works because it is included in the standard display template for refiners.
Hi Radu,
What do you mean by own Display template, changing filter_default.js file. I have separate Display templates for specific type of results and I included my resource file there, but havent changed the filter_default.js. It would be great if you can explain that in Brief.
Thanks
Shakthi
By “own display template” I referred to a separate display template, and you can use one of the standard display templates as reference. Your approach with a separate display template and where you include your resource files is the way to go…
I really liked your Posts for Localizion for Display templates, which helped to solve my other Problems..