Translate your forms into multiple languages using WPML and the Formidable Multilingual add-on.
Download and install
- If you haven't already, install and activate the current version of Formidable Forms Premium on your WordPress site.
- After confirming your Formidable Forms license, proceed to the Formidable → Add-Ons page and click the Install button for the WPML Multilingual add-on.
- Download and install the WPML core plugin and WPML String Translation add-on.
Translate a form
After the three WPML plugins and the Formidable Multilingual add-on are activated, you may follow the steps below to translate your forms.
- Go into edit a form that you would like to translate. Click on Settings and click the Translate Form button.
- Enter your translations. If you would like to prevent a translation from being used, uncheck the 'Complete' box.
- Publish your form on a page and use WPML to translate the page to any other languages you would like to use.
Translate a View
When translating Views, you need to create separate Views for each language. Follow the instructions below to get started.
- Create a View for the default language. For this example, use English.
- On the left sidebar of your View builder, look for the Metaboxes → Language section. Click the + Translate icon to create the translated View for the second language.
You will be redirected to a new View, where you can add your translation. - Publish the View for the default language.
- From the right sidebar of the page editor, look for the Page → Language section. Click the + Translate icon to create the translated page for the second language.
You will be redirected to a new page where you can add your translation. - You can either insert the Formidable shortcode manually or use the Formidable Views block to publish the second language View on the new page.
Set datepicker language
Follow these steps to make the datepicker field in your form use a different locale.
- Open the field settings for your date field and set the locale.
- Go to the form translation page for this form.
- Select your preferred datepicker language from the dropdown for each language you are translating to.
Sending translated emails
To send the email for the correct language, you'll need to set up multiple email form actions. Each of these emails will be sent conditionally, based on the language submitted.
- In your form builder, add a hidden field.
- Activate this code snippet and use [current_wpml_lang] as the default value for your hidden field.
- In your form Settings → General page, click the Translate Form button to add the translations for your form and publish it on a page.
- In your form Settings → Actions & Notifications page, create an email action for each language that you want to translate. Set them up however you'd like.
- To ensure that the correct email is sent depending on the language, add conditional logic to each one. For example, use en for English and es for Spanish.
Please note that Conditional Logic is only available in the premium version of Formidable Forms. Your conditional logic will look like this:
Translate success message
To translate the success message displayed after form submission, you must create a confirmation action for each language. The confirmation actions will be triggered based on the language submitted.
- To get the current language, add a hidden field in your form.
- Activate this code snippet and use [current_wpml_lang] as the default value for your hidden field.
- In your form Settings → Actions & Notifications page, create a confirmation action for each language you want to translate. Select the Show Message button to customize the message and add in your translation.
- Add conditional logic to each confirmation action to ensure the correct success message is sent depending on the language. For example, use en for English and fr for French. Your conditional logic will look like this:
Redirect based on site language
To redirect to the correct translated page after form submission, follow these steps to get the language that the user is viewing.
- Activate this code snippet to get the current language.
- Add a hidden field to your form and insert [current_wpml_lang] as the default value.
- Go to the form Settings → Actions & Notifications page and select the Confirmation action.
- Click the Redirect to URL button. In the Redirect URL box, enter the URL where you want users to be redirected, followed by ?lang=[x].
http://site.com/thank-you/?lang=[x]
Replace x with the ID of the hidden field containing the current language.
- In your WPML → Languages → Language URL format, choose the Language name added as a parameter.
Redirect Login Form
If you have added a Login form using the User Registration add-on, you might be redirected to the default language after logging in or logging out. To set up a redirect to the language you want to use, you could do the following:
- Go to your Login page and click Edit Translation. For this example, the default language is Spanish, and the second language is English.
- Insert the login shortcode on your page.
[frm-login redirect="/en/login/" logout_redirect="/en/login/"]
- If you have set your WPML Language URL format to set the Language name as a parameter, your shortcode could look like this instead:
[frm-login redirect="/login/?lang=en" logout_redirect="/login/?lang=en"]
Set the reCaptcha language
In your Formidable → Global Settings → reCaptcha, select "Browser Default" as the reCAPTCHA Language. This will set the browser language to be used for the reCaptcha.
Translate values in custom HTML
If you have content in the form Settings → Customize HTML page that you want to translate, follow the instructions below to get started.
- Activate this code snippet to get the current language.
- Surround the content with frm-condition to only show it if the current language matched. Use current_wpml_lang as the source.
- For example, if the current language is French and you want to display its translated value, your final shortcode may look something like:
[frm-condition source=current_wpml_lang equals="fr"]Afficher le contenu[/frm-condition]
Replace fr with your selected language.
Troubleshooting
Default language always shows
If the default language is always showing after setting up and saving your translation, this is usually related to settings in WPML. It works best if the default language in the WPML settings is the same and the default language set for the string translations.
English translation not working
If you have translated your form from a default language other than English (e.g. Italian), the translations may not show up. Try the following steps to resolve the issue:
- Go to the WPML → String translation page and search for the string that is not translating.
- Select the string and change the selected string language to your site's default language.
If this does not resolve the issue, please create a ticket in the help desk for assistance.
Conditional logic not working
If you have added conditional logic to a field, this may break when you translate your form to a non-default language. To resolve this issue, enable separate values in your radio, dropdown, and checkbox fields. This way, only the displayed value is translated and the conditional logic will work across languages.
Error: Call to a member function
If you see this error message, check each of the following:
- Are Formidable Forms, Formidable Forms Pro, and Formidable Multilingual up to date? If not, please update.
- Are WPML Multilingual CMS and WPML Translation Management up to date? If not, please update.
- Do you have the Polylang plugin installed? If so, you'll need to choose between the two. They are currently not designed to work together.
- Do you have another plugin installed that uses WPML or Polylang? If so, try deactivating it to check for a conflict.
Additional customizations
These code examples can be added to a child theme's functions.php file or the Code Snippets plugin (recommended). To learn more about how to use code examples like this, see the Formidable Hooks guide.
Get the current language
Use [current_wpml_lang] to get the current language by adding the code below.
add_shortcode( 'current_wpml_lang', 'current_wpml_lang' ); function current_wpml_lang() { return apply_filters( 'wpml_current_language', null ); }