diff --git a/docs/manual/docs/customizing-application/configuring-faceted-search.md b/docs/manual/docs/customizing-application/configuring-faceted-search.md index 292739175bc..15a35e166ec 100644 --- a/docs/manual/docs/customizing-application/configuring-faceted-search.md +++ b/docs/manual/docs/customizing-application/configuring-faceted-search.md @@ -338,6 +338,23 @@ When using a generic field like `tag.default` and including only a subset of key }, ``` +To translate the label `IDP_TOPICS`, 2 options: + +* Use the translation API to add your custom translation in the database for the facet key `facet-IDP_TOPICS` (see the Admin console --> Settings --> Languages). +* Or declare a meta property `labels` in the facet configuration: + +``` js +"IDP_TOPICS": { + "terms": { + ... + "meta": { + "labels": { + "eng": "IDP topics", + "fre": "Thèmes IDP" + }, +``` + + ## Decorate aggregations {#configuring-facet-decorator} All aggregations can be decorated by an icon or an image in the home page or in other pages. The decorator is configured in the `meta` properties of the facet: diff --git a/web-ui/src/main/resources/catalog/components/elasticsearch/directives/FacetDirective.js b/web-ui/src/main/resources/catalog/components/elasticsearch/directives/FacetDirective.js index 1f35bc45010..6b7f2d8ae38 100644 --- a/web-ui/src/main/resources/catalog/components/elasticsearch/directives/FacetDirective.js +++ b/web-ui/src/main/resources/catalog/components/elasticsearch/directives/FacetDirective.js @@ -266,7 +266,8 @@ module.directive("esFacets", [ "gnFacetSorter", "gnSearchSettings", - function (gnFacetSorter, gnSearchSettings) { + "$translate", + function (gnFacetSorter, gnSearchSettings, $translate) { return { restrict: "A", controllerAs: "ctrl", @@ -291,6 +292,14 @@ // Directive tab field property scope.isTabMode = scope.ctrl.tabField !== undefined; scope.facetSorter = gnFacetSorter.sortByTranslation; + + scope.getFacetLabel = function (facet) { + if (!facet.meta || !facet.meta.labels) { + return null; + } + var currentLang = $translate.use(); + return facet.meta.labels[currentLang]; + }; } }; } diff --git a/web-ui/src/main/resources/catalog/components/elasticsearch/directives/partials/facets.html b/web-ui/src/main/resources/catalog/components/elasticsearch/directives/partials/facets.html index aa7645dd73d..79f7cbfc23d 100644 --- a/web-ui/src/main/resources/catalog/components/elasticsearch/directives/partials/facets.html +++ b/web-ui/src/main/resources/catalog/components/elasticsearch/directives/partials/facets.html @@ -54,7 +54,7 @@ gn-collapsible="::ctrl.fLvlCollapse[facet.key]" > {{('facet-' + facet.key) | facetKeyTranslator}}{{getFacetLabel(facet) || (('facet-' + facet.key) | facetKeyTranslator)}}