We are using i18nviews and the patch from Bart (see #1106294: exposed term with depth filter not translated) and it's working pretty good.
The only problem we have is that some terms are not ordered by their name when they are translated.

In french:

  • Accoucheuse
  • Dentiste
  • Pharmacien

In Dutch:

  • Vroedvrouw
  • Tandarts
  • Apotheker

Drupal will render the second list according to the order(weight) of the terms in the original language (which is french here) and it will be hard for the user to find terms in the list if they are not ordered.

Proposed resolution

The correct solution should be:

  • Apotheker
  • Tandarts
  • Vroedvrouw

There is no 36 solutions to this problem, as we only have the weight to order elements, I've chosen to override it (for now) and order by the value of the option.
It means that ALL the exposed filters will be ordered in that way.

Maybe I'll try to insert an option to control it later, but for now I don't see how either where, ideas and improvements are very welcome.

Remaining tasks

Find a solution to enable the sort individually on each exposed filter.

Members fund testing for the Drupal project. Drupal Association Learn more


Pol’s picture

Here's the patch for 6.x-2.x version.

Cyclodex’s picture

Status: Active » Needs review

Thanks for this patch, I used this as a base for a D7 and i18n_views 7.x-3.x-dev patch.

I have the same issue, but not related/using depth. I have a single level taxonomy list, and do exposed filtering on them. The problem is/was that the term list in a different language was ordered always like the "base language" as you also described in this issue.
The patch didn't worked, but I only had to add a none object comparison and I am also using
strnatcasecmp — Case insensitive string comparisons using a "natural order" algorithm
Otherwise lower-case terms are after upper-case ones.

I was mainly searching and trying to fix the list of terms when creating, but didn't got it working yet. This form_alter() was the only way I got a nice ordered list of terms in other languages.

If this is really a good way, I can post a patch if you like. But I will also ask for how we could fix this generally and not only with hook_form_alter()

 * Implementation of hook_form_alter().
function i18nviews_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id != 'views_exposed_form')

  foreach (element_children($form) as $key) {
    if (!preg_match('/^tid/', $key) && !preg_match('/^term_node_tid_depth/', $key)) continue;

    uasort($form[$key]['#options'], '_i18nviews_option_value_compare');

    if ($form[$key]['#options']['All']) {
      $all = array('All' => $form[$key]['#options']['All']);
      $form[$key]['#options'] = $all + $form[$key]['#options'];

// Custom sorting using "natural order"
function _i18nviews_option_value_compare(&$a, &$b) {
  if (is_object($a) && is_object($b)) {
    return strnatcasecmp(reset(array_values($a->option)), reset(array_values($b->option)));
  elseif (is_string($a) && is_string($b)) {
    return strnatcasecmp($a, $b);

Cyclodex’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev

Can I move this to Version 7 or should I create a new issue related to this ?
I think because D7 is current Version and my code is related to this its fine, if not please change it back.
I only try to help ... ;)

I am also looking for other issues, and think we should fix this in general and not only with hook_form_alter().
Will also ask over here how / where we should fix this issue: #444732: translated taxonomy terms in alphabetical order
The code there is not working for me.

Regards Cyclodex

Cyclodex’s picture

Due this seems to be hard to better fix I just wanted to note, that I implemented some other hook_form_alter() to order all my select and checkboxes fields, finally I got a correct orderect list in a foreign language.
So the problem is done for me with this workaround.

Cyclodex’s picture

Issue summary: View changes

Updated template.

epringi’s picture

Issue summary: View changes

Hi there, is there any change on this issue?

I'm having the same problem where the translated results are not sorted in the target language but in the originating language.

Cyclodex, if your patching worked, that would be great if you could share a patch file. :)

Thanks. :)

mas0h’s picture

I'm in the same boat