CiviCRM in Drupal 8: multi-language capabilities

11 Oct 2019

CiviCRM has multi-language capabilities that are quite powerful, but I had considerable difficulty in finding simple documentation to describe how to set it up for Drupal 8 (Drupal 7 is better documented). So I have written my experience in the hope that it will help other newbies in the same position. 

My use case is a CiviCRM installation which is being used for the four main Nordic countries. We want to be able to expose forms in all four languages.

Adding interface language(s)

This is not so important for us, since administrators are proficient in English, but here is how to do it in Drupal 8.

The instructions at https://wiki.civicrm.org/confluence/display/CRMDOC/i18n+Administrator%2… are quite good, but it was only with the help of Michael O’Toole on the CiviCRM chat forum that I found out where to place the l10n folder in Drupal 8: under /vendor/civicrm/civicrm-core. Also the sql folder that comes with the tarball needs to be placed in the l10n folder. (But note, this may change - see https://lab.civicrm.org/dev/translation/issues/30)

With this achieved, and with a few cache-clears I was able to see and add languages on the localisation screen at /civicrm/admin/setting/localization?reset=1

Next it was not obvious to me that the Language Switcher block described at https://civicrm.org/blog/ayduns/language-switcher had to be placed in the Drupal blocks screen. The documentation appeared to suggest the block would appear automatically.

Once I had the block placed, it kind of worked, but multiple cache clears, both at the CiviCRM and Drupal side, seem to be needed periodically to get it to behave properly.

In any event, I now had the interface appearing in the languages I needed.

Adding multlingual functionality

Next up I enabled this feature at the bottom of the localisation screen at /civicrm/admin/setting/localization?reset=1. But I could not see how to manage the actual translation of field labels for forms. Fortunately Matthieu of civicrm.org helped me out on the chat. He explained that “when you edit forms (not on the initial creation), you will see translation icons”. Indeed I found that on the Edit forms the field labels have a very small black and white cube-shaped icon which when clicked pops up a box where translations can be input. Hallelujah, got there in the end!

I can then choose the displayed language on the public form by adding the language parameter to the url, e.g. &lcMessages=sv_SE for Swedish.

In conclusion

The above will be very obvious to those who know CiviCRM well, but for those of us who are coming to it new and who are not developers, it takes some digging to find out the basics. And I am sure I am missing or misunderstanding important stuff. Let me know if I am! And big thanks to Matthieu and Michael for their help, and to all at civicrm.org and in the CiviCRM community for all they are doing to make freely available such an awesome product.

Further reading

I found these further write-ups useful:

https://lab.civicrm.org/dev/translation/issues/13

Categories