Gravatar for

Question by helen, Oct 14, 2015 7:32 AM

How to change facet value in different languages

Hi Team, May I ask how to change facet value in different languages? For example : the template facet below, we would like to see '文章' instead of Article e.g. Type :

  • Article
  • Product

Regards, Helen

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Oct 14, 2015 7:53 AM

Hi Helen,

You have many choices for that but it depends on many factors.

If you have one indexed document per article per language, you can index the translated type directly in the indexed documents so the English article will have "Article" for the @type field and the Chinese article will have "文章" for the same field. That way, your facet will always display the same field and its values will depend on the search result set.

If you have only one indexed document per article:

If you are using the Coveo JavaScript Search Framework for your facet components, you can use the valueCaption option to define the translated version of each facet value. This approach is a bit harder because you need to render the translations at page load. Thus, you need to know the target language and all the possible facets values to be sure to cover them all.

If you are using the older Coveo .Net Front-End product, there's a similar feature in the facet properties page of the Interface Editor.

Gravatar for

Comment by helen, Oct 14, 2015 9:52 AM

Hi Jean, Currently we are using CoveoFacet.ascx wich is from Coveo for sitecore. But I dont know which property I can overwrite and how to overwrite. Your guidance would be much appreciated.

<coveoui:WhenConfigured runat="server">
        <% if (Model.IconProperties != null) { %>
            <%= Model.GetIconCss() %>
    <% } %>
    <div id='<%= Model.UniqueId %>'
         data-title='<%= Model.Title %>'
         data-field='<%= Model.Field %>'
         data-number-of-values='<%= Model.NumberOfValues %>'
         data-id='<%= Model.UniqueId %>'
         data-enable-collapse='<%= Model.EnableCollapse %>'
         data-enable-more-less='<%= Model.EnableMoreLess %>'
         data-enable-settings='<%= Model.EnableSettings %>'
         data-lookup-field='<%= Model.LookupField %>'
         data-sort-criteria='<%= Model.Sort %>'
         data-is-multi-value-field='<%= Model.IsMultiValueField %>'
         data-show-icon='<%= Model.ShowIcon %>'
         data-computed-field='<%= Model.ComputedField %>'
         data-computed-field-operation='<%= Model.ComputedFieldOperation %>'
         data-computed-field-format='<%= Model.ComputedFieldFormat %>'
         data-computed-field-caption='<%= Model.ComputedFieldCaption %>'
         data-include-in-breadcrumb='<%= Model.IncludeInBreadcrumb %>'
         data-number-of-values-in-breadcrumb='<%= Model.NumberOfValuesInBreadcrumb %>'
         data-include-in-omnibox='<%= Model.IncludeInOmnibox %>'
         data-enable-facet-search='<%= Model.EnableFacetSearch %>'
         data-facet-number-of-values-in-facet-search='<%= Model.NumberOfValuesInFacetSearch %>'
         data-allow-toggling-operator='<%= Model.AllowTogglingOperator %>'
         data-use-and='<%= Model.UseAnd %>'
         data-page-size='<%= Model.MorePageSize %>'
         data-injection-depth='<%= Model.InjectionDepth %>'
         data-available-sorts='<%= String.Join(",", Model.AvailableSorts) %>'></div>

Regards, Helen

Gravatar for

Comment by Jean-François L'Heureux, Oct 14, 2015 10:49 AM

The valueCaption option cannot be set with a data attribute like the ones in the CoveoFacet.ascx file. Setting it there would also impact all the facets on all your search pages.

By the way, it is not recommended to modify the files and items that Coveo for Sitecore installs because they will be overwritten the next time you will upgrade the software.

The valueCaption JavaScript object must be defined after the Coveo for Sitecore components options have been instantiated and before the components are initialized (Call to 'init'). This is done in a "Coveo Search" component. I recommend you to first duplicate the original Coveo Search component (see Duplicating the Coveo Search Component).

Then, you will need to add your captions in your new ascx file. You can refer to my answer on that question to do so:

Note that adding the captions on the CoveoForSitecore.componentsOptions.Facet object will affect all the facets on the search interface at the same time. If you want to define captions separately for each facet, you will need to set the captions to the different CoveoForSitecore.componentsOptions.FacetID objects where "FacetID" is the unique ID you set in the facet configuration.

Ask a question