Home » Documentation » Developers information » Translation for texts by other plugins and themes » How to use Contact Form 7 in multilingual websites

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:

  1. Contact form field names
  2. Text outside of field labels
  3. 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 [icl] tag.

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] and [/icl] tags:

[icl]Select Your Country[/icl]

Like in the previous example, let’s also add the string context to the translation tag.

[icl select-country-label]Select Your Country[/icl]

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.

Multilingual contact form

Multilingual contact form

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.[/icl]

Making the message multilingual

Making the message multilingual

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.

Need help?

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.

12 Responses to “How to use Contact Form 7 in multilingual websites”

  1. Al says:

    It took me a while to figure out that I should be making the changes related to icl codes inside the admin settings panel for the contact form 7 plugin.

    I can’t figure out from your instructions how to change the user feedback.

    I can’t edit the messages in the pluggin settings.

    Is there a messages file that needs to be modified?

  2. Al says:

    My Bad.

    The text is editable.

    For me, the user interface was such that I could not tell that I could edit the text.

  3. zxl says:

    Hi,
    How do I get the quiz to show up for string translation? My quiz tag is:

    [quiz quiz-530 "This year is the 60th anniversary of the founding of the People's Republic of China. In what year was the People's Republic of China founded?|1949"]

    I tried inserting ‘icl’ right after the [quiz quiz-530 part, but it still didn’t show up under string translation. In fact, I don’t see the quiz at all in the foreign language page.
    Thanks.

  4. Piet says:

    I haven’t tried this yet, but I am sure it will work brilliantly!

    My main reason for not trying this as of yet is that I am using a re-direct to a confirmation page. As this is obviously a different page per language, what would be the best way to go about this?

    Thanks to both the WPML team and takayukister for collaborating on this to making it work so well!

    Piet

  5. [...] après il vous faut un formulaire de contact. J’ai bien aimé Contact Form 7 qui plus est, est compatible avec WPML cité plus haut (cf ce tuto chez WPML) [...]

  6. enad says:

    hi i cant seem to figure out how to publish a form. i tried copying the tags but they just showed up as tags

  7. Peterek says:

    Hello WPML crew, thanks for your work!

    The plugin (v1.7.1) is perfect but I just can’t get it to (fully) work with contact-form-7 (v2.1.2). I am using wordpress 2.9.2

    It’s more related to CF7, but I will try here first :)

    The problem is related to wpcf7_get_request_uri() function which – for some reason – does not return url with language code. Consider a form placed here:

    http://mysite.com/en/contact-us

    Then the wpcf7_get_request_uri() function returns only “/contact-us” (so the form is submitted to “http://mysite.com/contact-us”). After submmiting form data to mysite.com/contact-us the emails are sent BUT user sees 404 error message (The “Your message was sent successfully. Thanks.” message is NOT displayed).

    I tried to hack CF7 code (include/classes.php, form_htm function) with the use of ICL_LANGUAGE_CODE constant, but simply it’s not defined until this code executes.

    Does anyone solved this kind of problem? Is it something with my site setup (.htaccess?), bug or configuration problem?

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">