How to use Contact Form 7 in multilingual websites
Starting with version 2.0, Contact Form 7 can create multilingual contact form using the WPML plugin.
Checklist for getting started:
- Install and enable WPML.
- Install Contact Form 7 v2.0 (or a later version) and activate it.
(the order for these operations can be reversed as well)
Open Contact Form 7′s admin page and begin to editing a contact form.
Making a contact form multilingual
There are three parts of Contact Form 7 which WPML can make multilingual:
- Contact form field names
- Text outside of field labels
- Feedback to visitors (what they get after submitting a form)
There are different procedures for translating each of the items above.
Making field names multilingual
To make form fields multilingual, add the
icl attribute to the tag.
For example, have a look at the following tag (country name for the contact form):
[select your-country "China" "India" "San Marino"]
To make it multilingual, visitors would need to see the different countries in their languages. Insert
icl before the list of options.
[select your-country icl "China" "India" "San Marino"]
The process about is fine. You can also use the following alternative syntax which also specify the text context. For following format tells the translation system that we’re translating a field called "country-names". It makes the translation easier as when we translate the strings, we know what we’re translating. To use it, insert
icl and then the field name (which is not translated itself).
[select your-country icl:country-names "China" "India" "San Marino"]
Translating text besides field names
In order to change make text that’s outside of field names multilingual (any other text in the form), wrap it in an
For example, supposing we’re translating the label for the country name selector:
Select Your Country
Wrap the text that needs to be translated with
[icl]Select Your Country
Like in the previous example, let’s also add the string context to the translation tag.
[icl select-country-label]Select Your Country
The result of what we just did appears below. This is a contact form (or at least part of it), which will appear fully multilingual to visitors.
Making user feedback multilingual
We’ll use a similar technique to translate the feedback that visitors see after submitting contact forms. This means, we’ll wrap the feedback text in
[icl] tags as well.
Let’s make the confirmation email multilingual.
Your message was sent successfully. Thanks.
Wrap it by
[icl] tags. Also, include the string context in the tag (so that we know what we’re translating later).
[icl success-response]Your message was sent successfully. Thanks.
Once we’ve done this procedure and wrapped everything that needs to be translated in [icl] tags, save the form. The form is ready to be displayed in multiple languages. To translate the strings, go to ‘WPML’->’String translation’. The texts you created in the contact form will appear them and you can provide translation to all the site’s languages. The contact form will display correctly in different languages and visitors will get feedback in their language.
CF7 author provides extensive support, including free documentation, paid troubleshooting and customization service. Check out the different CF7 support options and see which one is best for you.