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”?
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”?
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;
}
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?
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.
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';
}