How to translate fields on the registration page

If you sell to wholesale customers in more than one language, you’ll want your wholesale registration form to appear in each customer’s language. This article shows you how to translate the built-in registration fields, the custom fields you’ve added, and their dropdown options and default values.

Before you start

  • WooCommerce Wholesale Lead Capture 2.0.5 or later, for the custom field steps.
  • WPML with the String Translation module active, or Loco Translate or Poedit for the built-in fields.
  • At least one second language added to your site.

Translate the built-in fields

The built-in registration fields in WooCommerce Wholesale Lead Capture ship with translation-ready strings. You can translate them with Loco Translate, Poedit, or WPML.

With Loco Translate: go to Loco Translate → Plugins → WooCommerce Wholesale Lead Capture and translate the strings.

With WPML: go to WPML → Translations, open the Strings tab, and filter by the woocommerce-wholesale-lead-capture domain. If the plugin’s strings aren’t listed yet, use the Can’t find the strings you’re looking to translate? panel on the same screen to add them.

Loco Translate editor open on the WooCommerce Wholesale Lead Capture plugin strings

Translate custom field labels and placeholders with WPML

From WooCommerce Wholesale Lead Capture 2.0.5, the labels and placeholders of your custom registration fields are registered with WPML String Translation automatically. You don’t need any code to translate them.

  1. Open your wholesale registration page once in your site’s default language. Custom field strings are registered with WPML the first time the form loads.
  2. Go to WPML → Translations and open the Strings tab.
  3. Filter the list by the woocommerce-wholesale-lead-capture domain, or search for wwlc_custom_field_.
  4. Find the strings for your field. Each custom field has a label string named wwlc_custom_field_label_ followed by the field ID, and a placeholder string named wwlc_custom_field_placeholder_ followed by the field ID.
  5. Click the + icon under the flag of the language you want (for example, Add Spanish translation).
  6. Type your translation and press Enter to save it.
  7. Open the registration page in that language to check the translated label and placeholder.

For example, a custom field with the ID wwlc_cf_store has the strings wwlc_custom_field_label_wwlc_cf_store and wwlc_custom_field_placeholder_wwlc_cf_store. A placeholder string only appears if the field has a placeholder set.

WPML Translations screen on the Strings tab, filtered to the woocommerce-wholesale-lead-capture domain, showing custom field label and placeholder strings with the Spanish translation editor open
Spanish wholesale registration form showing the translated custom field label Tipo de negocio and its translated placeholder

Translate dropdown options and default values

WPML doesn’t pick up the dropdown options or default values of custom fields. For these, add a small code snippet (a filter) that swaps in your translated text for each language. Paste it into your child theme’s functions.php file, or add it with a code snippets plugin. In the examples below, replace the field ID, language codes, and translations with your own.

Default values

This snippet sets a different default value for the custom field in each language. The default value is the text that’s already filled in when the form loads.

add_filter("wwlc_registration_form_fields", function ($registration_form_fields) {
 
    $registration_form_fields2 = $registration_form_fields;
 
    foreach ($registration_form_fields as $key1 => $field) {
        // Target the field with ID 'wwlc_cf_store' and translate its default value
        if ($field['id'] == 'wwlc_cf_store') {
            switch (ICL_LANGUAGE_CODE) {
                case "en":
                    if (isset($field['default_value'])) {
                        $registration_form_fields2[$key1]['default_value'] = "Tell us about your business ";
                    }
                    break;
                case "fr":
                    if (isset($field['default_value'])) {
                        $registration_form_fields2[$key1]['default_value'] = "Your French Translation ";
                    }
                    break;
                // Add more cases for other languages if needed
            }
        }
    }
 
    return $registration_form_fields2;
 
}, 10, 1);

This filter targets the custom field by its ID and replaces its options for each language. The value of each option must match the original custom field option value. Only the text changes.

add_filter("wwlc_registration_form_fields", function ($registration_form_fields) {

    foreach ($registration_form_fields as $key1 => $field) {
        // Target the field with ID 'wwlc_cf_store'
        if ($field['id'] == 'wwlc_cf_store') {
            switch (ICL_LANGUAGE_CODE) {
                case "en":
                    if (isset($field['options'])) {
                        // Modify the value of the 'options' attribute
                        $registration_form_fields[$key1]['options'] = array(
                            array('value' => 'life', 'text' => 'life Text 1'),
                            array('value' => 'online', 'text' => 'online Text 2'),
                            // Add more options as needed
                        );
                    }
                    break;
                case "fr":
                    if (isset($field['options'])) {
                        // Modify the value of the 'options' attribute for French
                        $registration_form_fields[$key1]['options'] = array(
                            array('value' => 'life', 'text' => 'French life Text 1'),
                            array('value' => 'online', 'text' => 'French online Text 2'),
                            // Add more options as needed for French
                        );
                    }
                    break;
                // Add more cases for other languages if needed
            }
        }
    }

    return $registration_form_fields;

}, 10, 1);

The custom field in this example is a dropdown with the option values life and online:

Custom registration field settings showing a dropdown field with the option values life and online

Troubleshooting

My custom field strings aren’t showing in WPML

Open the wholesale registration page once, then reload the Strings tab under WPML → Translations. The strings are registered when the form loads.

If they still don’t appear, check that WooCommerce Wholesale Lead Capture is version 2.0.5 or later under Plugins → Installed Plugins. A placeholder string only appears if the field has a placeholder set.

My filter translations aren’t showing on the registration form

Check that the language code in your snippet matches the active WPML language (for example, fr for French), and that the snippet uses the exact field ID. A typo in either makes the filter skip the field without an error.

Frequently asked questions

Which translation tools work with wholesale registration page fields?
Loco Translate, Poedit, and WPML all support the built-in Wholesale Lead Capture fields. For Loco Translate, go to Plugins → WooCommerce Wholesale Lead Capture. With WPML, translate the strings under WPML → Translations, on the Strings tab.

Does WPML support translating custom fields on the registration form?
Yes. From WooCommerce Wholesale Lead Capture 2.0.5, custom field labels and placeholders appear in WPML String Translation under the woocommerce-wholesale-lead-capture domain. Dropdown options and default values still need a filter in functions.php.

Do custom registration fields translate automatically with a language plugin?
Not automatically, but WPML makes their labels and placeholders available to translate in String Translation. Loco Translate and Poedit can’t see custom fields, because the fields are stored in your site’s settings rather than in the plugin’s translation files.

Can I translate dropdown option values on the registration page?
Yes, with the filter shown above. Match each option’s original value in the array and return the translated text for each language code you support.

Need help?

If you have a question or run into any issues, we’re here to help.

Was this article helpful?

Related Articles

Complete Your Purchase