How to Translate WordPress Contact Forms

How to Translate WordPress Contact Forms (Step by Step)

Do you want to translate your WordPress contact forms into another language?

Translations are really important if your website serves people from different regions of the world where English may not be their first language.

The good news is that handling translations is really easy in WordPress. Remember, you’re not just translating words; you’re also opening doors to a wider audience. 🌐

In this article, we’ll show you how to translate your WordPress contact forms.

Create Your WordPress Form Now

How to Translate Your WordPress Contact Forms

For this tutorial, we’ll assume that you already have WPForms installed. Translations are handled slightly differently by every contact form plugin, so the steps below may not be accurate for other forms plugins.

Step 1: Create a Simple Contact Form

With WPForms installed and activated on your site, you can go ahead and start creating a form to translate.

Open your WordPress admin menu and go to WPForms » Add New.

Add new form

Once you’ve done that, you’ll be taken to the form setup screen. Start by giving a title to your form.

Naming your form

After that, scroll down to the template section and select one from over 1,900+ WordPress form templates. We’ll select the Simple Contact Form template for the purposes of this tutorial.

Use Contact Form Template

As soon as you press Use Template, the form template will start loading inside the form builder.

Contact form loaded

You can add additional fields to your contact form by dragging them from the left hand panel to the right hand panel.

Make sure to press the Save button to save the changes you’ve made to your form up until this point.

Step 2: Translate Your Form Fields

Translating your contact form’s fields is really easy to do in WPForms, and there are a few ways to do this.

Automatic Translation

If you’re following this method of translation, you should first publish your form using one of the embedding options offered by WPForms. Then follow the instructions below.

The fastest way to translate your form fields into any language is to use the Weglot plugin.

Weglot is a paid plugin that can instantly translate content on your site into any language simply by clicking a language switcher button.

It works with all kinds of content on a WordPress site, including forms built with WPForms. You can install Weglot using the same steps you followed to install WPForms.

Weglot

After installing the plugin, click Weglot from your WordPress admin menu sidebar.

Clicking on weglot menu

You’ll now see the Weglot settings screen.

In order to use Weglot’s translation services, you need to create an account with Weglot and use your API key to connect your account with WordPress.

Click on the Weglot link under API to create your Weglot account and get your API key.

Weglot link

Create your new account by entering your email address and password.

Weglot signup form

Weglot will send you a confirmation email. Click on the link inside the email and you’ll be redirected to your Weglot dashboard, where you can copy your API key.

Copy weglot API key

Now, switch your browser tab back to Weglot’s settings page on your WordPress site and paste your API key.

Paste weglot API key

You’ll also need to select the original language of your site. Then, select the destination language(s), which are the languages that you’d like to translate your content and forms into.

Then press the Save Changes button at the bottom.

Weglot will display a modal confirming that your site is now multilingual.

Weglot translation ready

Now, visit the page where you just published your contact form and use the language switches at the bottom to translate your form into another language.

Contact form in Espanol

As you can see, Weglot will translate your form field label, button text, and sublabels in your desired language.

However, no translation plugin can automatically translate validations and error messages in WPForms.

Validations not translated

So you’ll need to translate validation messages manually as shown in step 3.

Also, please bear in mind that Weglot is a paid plugin with a free trial for 10 days. To continue using its translation features after 10 days, you’ll need to purchase a paid plan.

If this isn’t the best option for you, we’ll show you how to translate your contact forms free of cost manually.

Manual Form Translations

It’s very easy to translate your forms manually in WPForms. To change the labels for any form field, all you have to do is click on the form field in the form editor and replace the default label with the language you want to translate your form into.

Field label in Spanish

If you need help with translating, you can use online translation tools like Google Translate to assist you.

After translating your form labels, you need to do something about the Name sublabels (the labels under the form fields like “First” and “Last”). While you can’t edit Name sublabels in WPForms, there is a way around this.

Click on a field you want to change the sublabel of to access its Field Options on the left-hand pane. Then click on the Advanced tab.

Advanced tab

While we can’t translate sublabels, we can still use custom placeholders instead of sublabels.

Insert your translations in the placeholder fields.

Translated placeholders

Then scroll down to the bottom and click on the Hide Sublabels toggle button.

Hide sublabels

You should also translate the Submit button text and the form name (if you originally used an English name for your form).

To do that, go to Settings » General from within the form builder.

General form settings in WPForms

On the right-hand pane, simply enter your translation inside the Form Name text box.

Changing form name

Scroll down to the bottom and repeat the same steps for the Submit Button Text and Submit Button Processing text boxes.

Submit text translation

Excellent! You’ve now translated all the labels and text inside your form. Go ahead and press Save and move on to the next step.

Step 3: Translate Your Form’s Validation Messages

A validation message is a text that appears when a required form field is left empty, or someone inputs incorrect data into a form field.

Validation message

To translate your contact form’s validation messages, exit your form builder and navigate to WPForms » Settings from your WordPress dashboard. Then click on the Validation tab.

Validation settings

From there, all you need to do is change the current validation messages (in English by default) to the language you’re translating your contact forms into.

Validations translated

Note: Make sure not to translate the text enclosed in curly brackets like {suggestion}. Changing this placeholder text can display gibberish in your error messages.

When you’re done, press Save Settings.

Save settings

Now, if you go and check your form by entering the wrong inputs or skipping a required field, you’ll see the translated validation messages appear.

Translated validation messages

And there you have it! You now know how to translate your WordPress contact forms.

While the above steps should be sufficient for most sites, there are certain special cases where you may need to use some PHP code to translate certain special fields.

We’ll show some of these in the next section so you can simply copy and paste code snippets even if you’ve never used any code before.

Bonus: Advanced Translation Options

Before we go into the details of different special scenarios, let us first explain how you can insert custom code snippets in your WordPress site in the easiest way possible.

To do this, you’ll need a plugin called WPCode. Install this plugin on your site.

WPCode plugin

After installing the plugin, hover your cursor over Code Snippets in your WP admin sidebar and click on Add Snippet.

Add snippet

Then, press the Use Snippet button under Add Your Custom Code (New Snippet)

Add your custom code snippet

This will open the code editor window.

WPCode editor

At the top, you can give a name to your snippet to help you reference it later. In the middle, you have the code editor, where you can write your own code or copy-paste it from another source.

At the top right, you can select your code type depending on the nature of your code. For these scenarios, we’ll be using PHP codes, so select PHP Snippet from the dropdown.

Code type

Excellent. Now, we’ll go through a few common scenarios where you may need to use PHP code in order to translate certain parts of your form.

Translating Validation Messages into Multiple Languages

Let’s consider a website that has forms in different languages on the same site. While you can easily change the labels manually or with the Weglot plugin as we’ve shown above, the validation messages can’t be changed for individual forms with these methods.

To change validation messages based on the specific language selected by a user on your site, you’ll need to insert a PHP code snippet.

We’ve created a code snippet that translates your form validation messages into Spanish or French based on the language selected by the user.

Follow the steps we’ve shown above to add a new snippet using WPCode, and then insert the following snippet inside the code editor:

PHP code for validation translations

Select the code insertion method (auto-insert, run everywhere).

Auto Insert code

Then, scroll back to the top and press the toggle button to set your code snippet to Active. Click on the Save Snippet button.

Save code

Congratulations! Your forms will now display validation messages in the selected language.

If you’d like to add translations for other languages, you’ll need the ICL language code for that language (this is ‘es’ for Spanish and ‘fr’ for French). Simply add a line of code starting with:

case '[insert your language code]':

Then, use the same blocks of code as appear in our example code above, right after the case line.

Add the translations for each validation message to the right of the equal sign inside square brackets as below (the specific validation message type is indicated by the double forward slashes):

//valid number
$strings[ 'val_number' ] = '[Enter your translation]'

And repeat for each line of code.

We’ve tested this code for WPML and Polylang plugins. Compatibility with other language translation plugins isn’t guaranteed.

Translating Email Confirm Field Sublabels

If you’re using the Email Confirm field, you may want to translate the sublabel into another language.

click to enable the email confirmation so that the sublabels will aappear

As shown in the previous example, you can do this with some custom PHP code inserted using WPCode.

Here’s the code you’ll need:

The translated text for the sublabels needs to be inserted on the right-hand side of the equal signs in the $properties functions.

For example, here’s how you’ll need to modify the above code for Spanish sublabels for the email confirmation fields:

$properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Introduce tu correo electrónico', 'plugin-domain' );
$properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'Para confirmar, vuelva a ingresar su dirección de correo electrónico aquí', 'plugin-domain' );

The code above will change the validation message for the email confirmation field globally on your site’s forms. However, it’s also possible to change it for individual forms only by modifying the above code slightly.

/**
 * Customize email field properties.
 *
 * @link https://wpforms.com/developers/how-to-change-sublabels-for-the-email-field/
 */
 
function wpf_dev_email_field_properties( $properties, $field, $form_data ) {
 
    // Only process this snippet on the form ID 123
    if ( absint( $form_data[ 'id' ] ) !== 123 ) {
 
        return $properties;
    } 
      
    // Change sublabel values
    $properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Enter Your Email', 'plugin-domain' );
    $properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'To confirm, re-enter your email address here', 'plugin-domain' );
  
    return $properties;
 
}
 
add_filter( 'wpforms_field_properties_email' , 'wpf_dev_email_field_properties', 10, 3 );

In the line of code if ( absint( $form_data[ 'id' ] ) !== 123 ), simply replace “123” with the actual form ID of the form you’re interested in.

You can locate the form ID by going to WPForms » All Forms and looking at the ID in the shortcode for your desired form.

How to locate a forms ID

Other Translation Options

If you’d like to translate some other specific fields and validations associated with only certain kinds of forms, you can check the following dev docs:

Next, Create Accordion Forms

An accordion design is a fantastic way to make a long form easier to fill with collapsible sections. Our detailed guide on creating accordion forms shows you all the steps for creating an accordion form in WordPress.

Create Your WordPress Form Now

Ready to build your form? Get started today with the easiest WordPress form builder plugin. WPForms Pro includes lots of free templates and offers a 14-day money-back guarantee.

If this article helped you out, please follow us on Facebook and Twitter for more free WordPress tutorials and guides.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPForms is funded, why it matters, and how you can support us.

Osama Tahir

Osama is a Senior Writer at WPForms. He specializes in taking WordPress plugins apart for testing and sharing his insights with the world. Learn More

The Best WordPress Drag and Drop Form Builder Plugin

Easy, Fast, and Secure. Join over 6 million website owners who trust WPForms.

Please enable JavaScript in your browser to complete this form.

2 comments on “How to Translate WordPress Contact Forms (Step by Step)

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.