How to translate Subscribe form module?

Hi,

How to translate Subscribe form module ? I need to change NAME and EMAIL ADDRESS to NAVN and E-POSTADRESSE.

Best regards
Johannes

Hi Johannes,

The topic I have linked below, has the code that will allow you to achieve your translation.

You will need to make some changes, but it should point you in the right direction.

Thanks,
Danny

Thank you Danny, do you have code for the contact for also? All fields and fieldsname?

regards
Johannes

Hi Johannes,

The topic I linked is for the contact form I believe.

Thanks,
Danny

Hi Danny, it was for the Subscribe form module and not the Contact form module. They are different…

regards
Johannes

Hey Johannes,

Just wondering why you needed to translate it manually? Is our translation incorrect? Or are you trying to translate it to a language we don’t have a translation for yet?

There are actually 2 ways to translate those texts. First is via module override. This is pretty complicated as we need to edit the theme files. Check out the link below for more info.
http://forum.wpbeaverbuilder.com/custom-module-documentation/#override-built-in

The files you’ll need to edit are under /bb-plugin/modules/contact-form/includes/frontend.php and /bb-plugin/modules/subscribe-form/includes/frontend.php should you wish to go that route.

The second method is via a function, like on that thread Danny referred you to above. You can use this function to replace the Name field label.

// Translate the word Name field label on the Contact Form module
function my_text_with_context_translations( $translated, $text, $context, $domain ) {
  if ( 'fl-builder' == $domain ) {
    if ( 'Name' == $text && 'Contact form field label.' == $context ) {
      $translated = 'Translation here'; 
    }
  }
  return $translated;
}
add_filter( 'gettext_with_context', 'my_text_with_context_translations', 10, 4 );

Then the function below to replace everything else. Simply add another case to the code as needed. Also, it’s case sensitive.

// Translate labels on the Contact Form module
function my_text_translations( $translated, $text, $domain ) {
  switch ( $translated ) {
    case 'Your name' :
    $translated = __( 'Translation here', 'fl-builder' );
    break;
    case 'Email' :
    $translated = __( 'Translation here', 'fl-builder' );
    break;
  }
  return $translated;
}
add_filter( 'gettext', 'my_text_translations', 20, 3 );

Hope this helps! :slight_smile:

Ben

“Just wondering why you needed to translate it manually? Is our translation incorrect? Or are you trying to translate it to a language we don’t have a translation for yet?”

Hi, thank you. I was not aware about Norwegian translation.

regards
Johannes

Gotcha! Try using the methods above and see if it works! :slight_smile:

Ben