I have used country_get_list() function to render all pre-installed countries in my select list.

When my site is in English, it is showing all country names in English, which is fine. But for French site, I want all country names should get translated in french.

For example: in English a country name is India but in the French site, it should display like Inde.

Is this possible to achieve?

  • Make sure you have the translated country strings in your database, ready to be used.
  • country_get_list() calls _country_get_predefined_list(), and inside this function country names are passed through t(). So, if you have country strings translated in your database, translation should work.
| improve this answer | |
  • Oh! so it means, I should convert all english text to french? Any easy way, as it would be so lengthy to replace every country name with French country name. – Sugandh Khanna Oct 14 '16 at 13:53
  • @SugandhKhanna I don't quite understand your comment here, can you try again to explain what you mean? – Pierre.Vriens Oct 14 '16 at 13:58
  • 1
    @SugandhKhanna, you can download the Drupal French translation from localize.drupal.org/download I just confirmed that it has the country names translated. – juankvillegas Oct 14 '16 at 16:23

It should be fixed by downloading the Drupal Core translation to the language you need from https://localize.drupal.org/download.

Once you have that file downloaded just go to admin/config/regional/translate/import and import the file there in the needed language. That's all.

This will not only translate the country names but all the Drupal Core interface.

You can also use the Localization update module to download translations for enabled languages for Drupal Core and contributed modules.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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