Translate the views' BEF filter labels

By roberto, Fri, 09/30/2022 - 09:56

Today I found a way to translate the - Any - entry used in the views' exposed filters. In my specific case, the filter retrieves the values ​​from a taxonomy that groups the site's news in categories; I also used the Better Exposed Filter module to view the filter entries as links.

I'm leaving out all Drupal's multi-language configuration parts because if your problem is translating the filters, I think you already have a multi-language site configured. In any case, I leave you the link to the official guide for further information.

Translating taxonomy entries is not a problem, just use the interface offered by Drupal. As for the - Any - entry, the question becomes a bit tricky. Here's what I did:

  1. I translated the text - Any - from the Drupal translation interface (/admin/config/regional/translate)
    User interface translation
  2. rewritten the text - Any - to be displayed in the various languages ​​inside the BEF settings
    Better Exposed Filters settings
    Better Exposed Filters rewrite

I hope it helps and if anyone has found a better way to handle this let me know. Thank you.