PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

change languages for one form only?

  1. I have a site in Danish, translation is working fine, http://kirstendyrum.com/
    but I wan´t a single form to be in English and one in German. How can I change the language for one form “manually”?

    Posted 13 years ago on Monday January 31, 2011 | Permalink
  2. You will need to use the available hooks to translate the sublabels (for the name, address and file upload fields) and the validation message. NOTE: Remember to replace the form IDs in the code snippets below with your form IDs.

    add_filter("gform_name_first", "change_name_first", 10, 2);
    function change_name_first($label, $form_id){
         if($form_id == 12)
           return "German First Name";
         else if($form_id == 13)
           return "First Name";
         else
           return $label;
    }

    Following are all the available sub-label hooks.

    * gform_name_prefix
    * gform_name_first
    * gform_name_last
    * gform_name_suffix
    * gform_address_street
    * gform_address_street2
    * gform_address_city
    * gform_address_state
    * gform_address_zip
    * gform_address_country
    * gform_postimage_file
    * gform_postimage_title
    * gform_postimage_caption
    * gform_postimage_description

    Use the following to translate the validation message

    add_filter("gform_validation_message", "change_message", 10, 2);
    function change_message($message, $form){
         if($form["id"] == 12)
            return "German validation message";
        else if($form["id"] == 13)
            return "English validation message";
       else
            return $message;
    }
    Posted 13 years ago on Tuesday February 1, 2011 | Permalink
  3. netagence
    Member

    Hello,
    I have exactly the same need but didn't manage to get a result.
    I implemented in functions.php:

    add_filter("gform_name_first", "change_name_first", 10, 2);
    function change_name_first($label, $form_id){
           return 'toto';
    }
    apply_filters( 'gform_name_first', array('prenom',1));

    but it didn't work
    What did I do wrong?

    Posted 13 years ago on Monday February 7, 2011 | Permalink
  4. You shouldn't need the "apply_filters" line as Gravity Forms will process the hook when required. I tested your code without that line and it is working fine on my localhost.

    Posted 13 years ago on Monday February 7, 2011 | Permalink
  5. Remove the last line and try again. Other than that, the code looks right.

    add_filter("gform_name_first", "change_name_first", 10, 2);
    function change_name_first($label, $form_id){
           return 'toto';
    }
    Posted 13 years ago on Monday February 7, 2011 | Permalink