I have a view displaying some nodes of a content type. Each node has a location assigned (with the location module).

I want to group and sort the results by countries. The grouping works fine, and the sorting is almost fine too.

It does sort by country, but it does it using the english countries' names.

However, my website is in french, so I want it to sort using the french countries' names.

Most of the countries are fine, but some are not the same. For example: South Korea is Corée du Sud in french, so it's not the same order.

Views uses the english name to sort, I want it to use the current language (here french, but it's a multilingual website, so also english when it is).

1 Answer 1


Your problem is that views uses SQL to sort, since that is a lot easier and faster and it otherwise would be required to load all the records and sort them with PHP, before selecting which to show, which is a massive resources waste if you have a lot of records and use paging.

A simple solution to this problem, is to create a work around. Since the country names is stored in english, you can create a field that you hide from the user where you store the French country name. You can then in your view use this field when sorting. You would need to write a bit of code - in a custom module you create - to hide the field in the UI and automatically set the correct value based on the country the user selected in the interface. This can all be done with hook_form_alter.

  • So I have to create a new field in the database? This seems like an issue to raise in views' (or location) issues queue. Jul 23, 2012 at 10:25
  • Just create a new field with the Field UI.
    – googletorp
    Jul 23, 2012 at 10:50
  • Oh, I see what you mean. Well... that seems damn ugly, but I guess there's no other way. Jul 23, 2012 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.